diff options
author | Carlo Zancanaro <carlo@clearboxsystems.com.au> | 2013-06-21 10:42:56 +1000 |
---|---|---|
committer | Carlo Zancanaro <carlo@clearboxsystems.com.au> | 2013-06-21 10:42:56 +1000 |
commit | fb946311da111e2a422a938b0b8720c3ecf3341c (patch) | |
tree | 3a060344dcf2d8d0ad84040de505de3008441da4 /src/clojure_sql/jdbc.clj | |
parent | 7377eee7fe3c81522680151bfd5ac3b120b87a30 (diff) |
Add take/drop, move jdbc stuff, document default of postgres
Add take and drop functionality to the queries, so now you can use the take and
drop functions in a similar way to how they work on seqs in clojure.
Move jdbc interface stuff into clojure-sql.jdbc, so if you're using jdbc you
can include it yourself. (If you're not using jdbc then it shouldn't bother
you).
Given the default compilation target is actually postgres, document that.
Diffstat (limited to 'src/clojure_sql/jdbc.clj')
-rw-r--r-- | src/clojure_sql/jdbc.clj | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/clojure_sql/jdbc.clj b/src/clojure_sql/jdbc.clj new file mode 100644 index 0000000..8611336 --- /dev/null +++ b/src/clojure_sql/jdbc.clj @@ -0,0 +1,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))))))) |