Blue JDBC is a new Clojure interface to JDBC with an an emphasis on ease-of-use, performance, extensibility.
java.time
everywhere!java.sql.PreparedStatement
and java.sql.ResultSet
are reducible/transducible and sequable. Wow!UUID
to a String for MySQL and a byte array for Postgres!(jdbc/query "jdbc:postgresql://localhost:5432/test-data?user=cam&password=cam"
"SELECT now() AS now;")
;; ->
[{:now #object[java.time.OffsetDateTime 0x75355ea0 "2020-04-22T05:36:46.257644Z"]}]
(jdbc/query-one a-datasource ; instance of java.sqlx.DataSource
{:select [:*]
:from [:checkins]
:left-join [:venues [:= :checkins.venue_id :venues.id]]
:where [:= :venues.id 25]}
{:results/xform jdbc/namespaced-maps-xform}
;; ->
{:checkins/date #object[java.time.LocalDate 0x60156e1b "2014-11-16"]
:checkins/id 12
:checkins/user_id 5
:checkins/venue_id 25
:venues/category_id 50
:venues/id 25
:venues/latitude 37.7818
:venues/longitude -122.396
:venues/name "Garaje"
:venues/price 2}
One might wonder whether the world needs another Clojure JDBC library. For many years,
clojure.java.jdbc
was the go-to Clojure JDBC library. I've personally spent
hundreds if not thousands of hours working with it as part of Metabase.
Sean Corfield's successor library, next.jdbc
, fixes some of the
shortcomings of clojure.java.jdbc
and makes some big improvements.
Blue JDBC shares a similar role as next.jdbc
as a successor to clojure.java.jdbc
, but with slightly different aims:
java.time
, currency types, Postgres JSON columns, and more mean the
low-level boilerplate is part of the library and not your part of your project.Blue JDBC currently runs tests against:
To run tests against a DB of your choice, set the environment variable JDBC_URL
and run lein test
:
JDBC_URL='jdbc:postgresql://localhost:5432/bluejdbc_test?user=cam&password=cam' lein test
Blue JDBC will automatically do the right thing based on the protocol.
Can you improve this documentation?Edit on GitHub
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close