Created
December 22, 2011 07:34
-
-
Save bizenn/1509383 to your computer and use it in GitHub Desktop.
with-connections -- Handling database multi-connection explicitly
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(require '[clojure.java.jdbc :as sql]) | |
(defmacro with-connections | |
"" | |
[bindings & body] | |
(cond (empty? bindings) `(do ~@body) | |
(symbol? (bindings 0)) `(sql/with-connection ~(bindings 1) | |
(let [~(bindings 0) (sql/connection)] | |
(with-connections ~(subvec bindings 2) ~@body))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment