Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use a database with Clojure

What methods to use a database from Clojure are there?

I know from Clojure you can do anything you can with Java, but that means that I may end up using something overly complicated (like Hibernate) which clashes with Clojure simplicity. Any recommendations or comments?

like image 419
pupeno Avatar asked Nov 17 '08 03:11

pupeno


2 Answers

clojure-contrib has an sql library which is a thin wrapper around JDBC (java.sql.DriverManager). The test file that comes with it has some examples of its usage.

like image 97
Brian Carper Avatar answered Sep 22 '22 19:09

Brian Carper


I would now (as of late 2011) recommend Korma - "Tasty SQL for Clojure"

It's a beautiful little SQL DSL, here's an example from the website:

(select users
  (aggregate (count :*) :cnt)
  (where (or (> :visits 20)
             (< :last_login a-year-ago))))
like image 42
mikera Avatar answered Sep 20 '22 19:09

mikera