SQL Korma

Now that we’ve Clojurized our front end, let’s look at doing the same to our model. Up to now we’ve been using clojure.java.jdbc and writing SQL queries by hand. SQL Korma is a native Clojure DSL that allows us to write the queries using Clojure.[62]

Korma provides a way to write composable queries using Clojure that are translated to the resulting SQL. Because the DSL mimics SQL structure, the resulting queries are efficient and human-readable. The first thing we need to do is include the Korma dependency in our project:

 
[korma ​"0.3.0-RC5"​]

We can now remove the org.clojure/java.jdbc dependency, as Korma depends on it and will ensure that it’s pulled into our project. To use Korma, we simply need to wrap our connection using ...

Get Web Development with Clojure now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.