Created
February 6, 2018 22:39
-
-
Save taylorwood/39ffc1f9a58e529c1b79e45ca498f252 to your computer and use it in GitHub Desktop.
Clojure JDBC Postgres streaming resultset
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
(defn query-lazy ;; adapted from https://stackoverflow.com/a/39775018 | |
[[sql & params] & {:as opts}] | |
(jdbc/with-db-transaction [tx (db/connection)] | |
(jdbc/query tx | |
(into [(jdbc/prepare-statement (:connection tx) sql {:fetch-size 100})] params) | |
opts))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment