Hey everyone,

We've been exploring ways to make working with database code more efficient 
and less error prone.
For complex queries, we prefer working directly with SQL. However, like for 
many others, a lot of our 
queries are very simple and repetitive. For example, retrieving or updating 
single rows, or a set of rows 
based on a foreign key. 

As an experiment, we wrote a prototype that uses the information_schema 
standard to automatically 
extract the schema from a database and represent it as clojure code at 
compile time. With this, we 
were able to synthesize some simple SQL queries. The interesting part of 
this is that the code generator
automatically picks up primary key constraints and also performs validation 
on table and column names.
All of this is done at compile time. Errors are caught early and the 
compiled code uses clojure.java.jdbc
prepared statements. You can find the code and demo here:

https://github.com/diligenceengine/edl

I'm personally not a big fan of huge ORM systems, so I don't know where to 
go with this, if anywhere.
Though it seems useful for building small macros for common patterns we 
have. 

Would love to hear if anyone has thoughts on the technique.

Alex



-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@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+unsubscr...@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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to