summaryrefslogtreecommitdiff
path: root/src/clojure_sql/jdbc.clj
blob: 86113363f7b0c8e8d655ccf25227cc08d9c13a55 (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
(ns clojure-sql.jdbc
  (:require [clojure.java.jdbc :as jdbc]
            [clojure-sql.core :refer [set-query-executor!]]))

(defn use-jdbc! [connection-string]
  (set-query-executor! (fn [type query] 
                         (jdbc/with-connection connection-string
                           (case type
                             :select (jdbc/with-query-results results query
                                       (vec results))
                             :insert (jdbc/do-prepared-return-keys (first query) (next query))
                             (jdbc/do-prepared (first query) (next query)))))))