Skip to content

Instantly share code, notes, and snippets.

@tlrobinson
Created March 9, 2018 08:23
Show Gist options
  • Save tlrobinson/6c8db4131b9ec4e536c1c32fc4b93d70 to your computer and use it in GitHub Desktop.
Save tlrobinson/6c8db4131b9ec4e536c1c32fc4b93d70 to your computer and use it in GitHub Desktop.
jooq in clojure
(def conn (java.sql.DriverManager/getConnection "jdbc:postgresql://localhost:5432/db", "", nil))
(def ctx (org.jooq.impl.DSL/using conn org.jooq.SQLDialect/POSTGRES))
(defn parse-sql [query] (.parseQuery (.parser ctx) query))
(defn select [body] (.select ctx body))
(defn inline [value] (org.jooq.impl.DSL/inline value))
(def a (select (inline 1)))
(def b (parse-sql "select 1"))
(log/info a)
(log/info b)
(log/info (= a b))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment