Current best-of-breed JDBC libraries?

734 views
Skip to first unread message

Colin Yates

unread,
Feb 24, 2015, 9:04:36 AM2/24/15
to clo...@googlegroups.com
Hi all,

What are you all using for interacting with an RDBMS? In the past I looked at clojure.java.jdbc, honeysql and korma (and for querying, honeysql just rocks). I have lost touch a bit - any recommendations?

Thanks.

Colin Yates

unread,
Feb 24, 2015, 9:11:16 AM2/24/15
to clo...@googlegroups.com
Actually, https://github.com/krisajenkins/yesql, now that it supports named parameters is probably just the ticket...

Andrey Antukh

unread,
Feb 24, 2015, 9:25:19 AM2/24/15
to clo...@googlegroups.com
I'm currently using and maintaining this two:

https://github.com/niwibe/clojure.jdbc - A clojure.java.jdbc alternative.
https://github.com/niwibe/suricatta - High level Sql toolkit (slightly higher level abstraction over plain jdbc and includes sql dsl)

Cheers.
Andrey

--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clo...@googlegroups.com
Note that posts from new members are moderated - please be patient with your first post.
To unsubscribe from this group, send email to
clojure+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups "Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clojure+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--

Niels van Klaveren

unread,
Feb 24, 2015, 10:12:41 AM2/24/15
to clo...@googlegroups.com
I've done a fair bit of complex SQL with honeysql, and must say it rocks. It could use a bit more documentation where extending it with new clauses is concerned, though.

For my latest project being able to manipulate the datastructures that are rendered to SQL was crucial, and honeysql was the only one that fitted that bill. Basically, it generates SQL scripts to relink foreign key references to clean up duplicates in a database. It takes a honeysql select query with (at least) a from table, a group-by and an order-by clause as a base definition what are to be considered doubles, and in which order records should be preserved. In combination with JDBC metadata that query effectively gets rewritten to generate:

A temporary replacement table
Queries to unify unique indexes, to prevent clashes when foreign key references are updated
Queries to update all foreign key references
Delete statements to remove all duplicates

To create the best performing, but still database independent SQL, I had to extend honeysql with extra clauses like OVER and PARTITION BY. I wouldn't say it was a breeze, but seemed to work very well.
Compared to the previous version I wrote in Ruby (without these clauses), the SQL now only scales with the amount of unique / foreign key constraints, instead of the amount of doubled sets.

That cut down SQL to (sometimes) GB's of script to around a few 100 lines of SQL, and on one occasion, a runtime from 19 hours to 1.5 minutes.

All in all, pretty impressed with Clojure and HoneySQL.

Colin Yates

unread,
Feb 24, 2015, 10:23:00 AM2/24/15
to clo...@googlegroups.com
+1 to all of that. We are using honeysql to serve our ad-hoc reporting
engine. Composing data structures for the win.

On 24 February 2015 at 15:12, Niels van Klaveren

Erik Price

unread,
Feb 24, 2015, 10:41:37 AM2/24/15
to clo...@googlegroups.com

We tried Korma but found it too limiting for our needs. Later, I saw this tweet:

https://twitter.com/ibdknox/status/557236505639665664

We are currently using HoneySQL to generate SQL which then gets passed to clojure.java.jdbc.

e


--

Sean Corfield

unread,
Feb 24, 2015, 11:50:55 AM2/24/15
to clo...@googlegroups.com
On Feb 24, 2015, at 6:04 AM, Colin Yates <colin...@gmail.com> wrote:
> What are you all using for interacting with an RDBMS? In the past I looked at clojure.java.jdbc, honeysql and korma (and for querying, honeysql just rocks). I have lost touch a bit - any recommendations?

At World Singles, all our MySQL interaction is done through clojure.java.jdbc (which I maintain), and HoneySQL for our more complex reporting queries. We like the composability of HoneySQL for complex stuff.

We have a small wrapper around clojure.java.jdbc for basic CRUD stuff (get-by-id, delete-by-id, find-by-keys) that encapsulates the identifier/entity mappings and the DB connections we use, but we’re slowly moving away from that toward raw clojure.java.jdbc and leveraging the :row-fn and :result-set-fn keys more.

Sean Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/

"Perfection is the enemy of the good."
-- Gustave Flaubert, French realist novelist (1821-1880)



Colin Yates

unread,
Feb 24, 2015, 12:16:39 PM2/24/15
to clo...@googlegroups.com
OK - thanks all.

I am surprised that yesql isn't more adopted, particularly now named
parameters is there - has anyone run into roadblocks with it?

Sean Corfield

unread,
Feb 24, 2015, 1:11:14 PM2/24/15
to clo...@googlegroups.com
On Feb 24, 2015, at 9:16 AM, Colin Yates <colin...@gmail.com> wrote:
> I am surprised that yesql isn't more adopted, particularly now named
> parameters is there - has anyone run into roadblocks with it?

Most of our SQL is dynamically created -- data-driven -- so YeSQL isn't really a good fit, as I understand it. We're either building SQL from a map of key/value pairs or from composable pieces using HoneySQL (for our complex reports that are all driven by data as well).

Colin Yates

unread,
Feb 24, 2015, 1:17:16 PM2/24/15
to clo...@googlegroups.com
Honeysql has to be one of the best examples of data transformation
where Clojure really shines. {domain-data} -> {honey-sql data} -> SQL.
Love it.

I understand YeSQL's sweet spot is where the SQL is static except for
parameters so yeah, not applicable for building up queries at runtime.
Still, if SQL is known up front then it seems very nice.

Niels van Klaveren

unread,
Feb 24, 2015, 1:24:30 PM2/24/15
to clo...@googlegroups.com
Perhaps I'm missing something, but I don't really see the advantages of yesql over standard parametrized clojure.java.jdbc queries ?

Colin Yates

unread,
Feb 24, 2015, 1:40:55 PM2/24/15
to clo...@googlegroups.com
I haven't used it but I remember building up pages of SQL in Clojure
wasn't fun. The idea of putting that SQL into a .sql file, accessible
by non-Clojure DB developer is very appealing.

On 24 February 2015 at 18:24, Niels van Klaveren
<niels.va...@gmail.com> wrote:
> Perhaps I'm missing something, but I don't really see the advantages of yesql over standard parametrized clojure.java.jdbc queries ?
>

blake

unread,
Feb 24, 2015, 6:05:29 PM2/24/15
to clo...@googlegroups.com
I ran through all of the above and found it easier just to build my queries straight and call with clojure.java.jdbc. But my needs were light.

Gary Johnson

unread,
Feb 24, 2015, 8:31:30 PM2/24/15
to clo...@googlegroups.com
I actually prefer yesql for most of my Clojure<->SQL interaction.

Since a significant portion of my job involves me writing and optimizing SQL queries, I like being able to seamlessly switch between psql, org-babel's sql mode, and yesql with a simple cut and paste operation. For extra emacs sexiness, check out the yesql-ghosts package in MELPA. This automatically inserts all of the imported function signatures (as defns) as a text overlay below any (defqueries ...) form when a clojure buffer is in cider-mode.

Keep on hackin' in the free world,
  ~Gary
Reply all
Reply to author
Forward
0 new messages