ClojureQL - 0.9 approaching 1.0

12 views
Skip to first unread message

Lau_of_DK

unread,
Jun 29, 2009, 2:01:35 PM6/29/09
to Compojure
Dear community,

Meikel and I have been driving an effort to get ClojureQL to version
1.0.

For those who do not yet know about ClojureQL, its a database adapter
which allows you to interface with MySql, Derby, Sqlite etc, without
ever leaving your lisp syntax. But more than being a syntax thing,
ClojureQL also is able to extend the functionality of databases, ie.
you can currently find an emulator in the backend which enables both
MySql and Derby to do FULL joins - Not something you normally get to
do.

In terms of functionality we almost cover every need that you'll have
when working with SQL, but there are still quirks to be ironed out
(ex. joins) and features to be added and extended (ex. alter table).
But this is where we'd like to appeal to the community to hit us with
some feedback! If you're interested in Clojure/SQL and you can find
the time to experiment a little, its as simple as this.

1) Put the src/ or the jar file on your class-path and get a REPL
going.
2) user> (use 'dk.bestinclass.clojureql) // Import the functions
3) Have fun, ala:

user> (def *connection* (make-connection-info "mysql" "//localhost/
cql" "cql" "cql"))
#'user/*connection*
user> (load-driver "com.mysql.jdbc.Driver")
com.mysql.jdbc.Driver
user> (run [*connection* results] (query * test)
(take 3 results))

({:id 1, :age 224} {:id 2, :age 23} {:id 3, :age 402})

If you run into trouble, because somethings is not currently
implemented, you can always resort to using (raw "SELECT * FROM foo
USING SPECIAL FUNC") or something similar - So you wont be stuck. If
you come across some features that are lacking, bugs that need
reporting or similar, please drop us a message at IRC or Github,
you'll find the project here: http://github.com/Lau-of-DK/clojureql/tree/master

Expect Join/Run syntax to change in the near future, and dont be
surprised if you come across something that needs a patch - We're not
1.0 yet, and we could use a little help in getting there :)

/Lau

James Reeves

unread,
Jun 29, 2009, 3:34:54 PM6/29/09
to Compojure
On Jun 29, 7:01 pm, Lau_of_DK <lau.jen...@bestinclass.dk> wrote:
> Meikel and I have been driving an effort to get ClojureQL to version
> 1.0.

I think everyone in the Compojure group is also in the Clojure group,
so there's no need to cross post.

Your ClojureQL project is interesting, though. Have you considered
using a similar syntax to clojure.set?

- James

Lau

unread,
Jun 29, 2009, 4:26:46 PM6/29/09
to Compojure
Hi James,

I apologize for double-posting - Hadn't thought that far :)

We haven't specifically tried to copy the syntax of clojure.set -
We've tried to keep a focus on both consistency and also something
that would come near to an intuitive transition from regular SQL
without loosing the lispyness of Clojure. In certain areas we've had
to do something new, like for instance with join. Intuitively, this
might seem most natural

(join :left [q1.c q2.x] (query q1 [a b c]) (query q2 [x y z]))

But we wanted something that would allow the WHERE predicates to
transcend the individual queries, so we are going with

(join :inner [t1.a t2.x] (query [t1.a t2.x t2.y] [t1 t2] (and (< t1.a
5) (= t2.y "foo"))))

In this way, we're a little shaped by ease of use, and a little by the
possibilities that we have to work with.

If you have some examples of syntax from Clojure.set which you would
like us to consider, I'd love to see it.

/Lau
Reply all
Reply to author
Forward
0 new messages