                              )                           )
                          )
                     []]
-                    :results)
+                    :results))
     )))
 
 

  ([sql-in params]
  (do
    (let [
          lower           (.toLowerCase sql-in)
          ]
      ;(println "SQL from client: " sql-in)
      (cond
       (.startsWith lower "select")  (do (comment println "SELECT") (korma.core/exec-raw [sql-in params] :results))
       :else                         (do (comment println "INSERT") (korma.core/exec-raw [sql-in params]) [])
   ; []
    )))
  )
)


)







(defn to-lower-case-keys [m]
      (into (empty m) (for [[k v] m] [(keyword (.toLowerCase (name k))) v])))




(defn db-count-records [table-name]
    (:cnt
      (to-lower-case-keys
     (first
     (korma.core/exec-raw
                   [(str "SELECT COUNT(*) as CNT FROM " table-name)
                    []]
                    :results))
    )))

(defn db-table-fields [table-name]
    (keys
      (to-lower-case-keys
     (first
     (korma.core/exec-raw
                   [(str "SELECT * FROM " table-name
