Skip to content

Instantly share code, notes, and snippets.

@taylorwood
Created February 6, 2018 22:39
Show Gist options
  • Save taylorwood/39ffc1f9a58e529c1b79e45ca498f252 to your computer and use it in GitHub Desktop.
Save taylorwood/39ffc1f9a58e529c1b79e45ca498f252 to your computer and use it in GitHub Desktop.
Clojure JDBC Postgres streaming resultset
(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