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?
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.
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))))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With