# clojure-sql A DSL for [Clojure][1] to compose queries using the constructs of [Relational Algebra][2]. The RA constructs are then compiled into an SQL query to be run on a DBMS. `clojure-sql` doesn't connect to a database itself, but rather can be configured to perform an action when a query is dereferenced. `clojure-sql` provides some utility functions beyond strict RA to allow for data to be inserted, updated and deleted. `clojure-sql` provides no mechanism to create database schemas. [1]: http://clojure.org/ [2]: http://en.wikipedia.org/wiki/Relational_Algebra ## Database support `clojure-sql` aims to have an extensible compiler. Compilation of queries is performed by multimethods which dispatch on an arbitrary (and otherwise unused) `db` parameter. This allows the compilation of queries to be entirely special-cased per database. By default `clojure-sql` will produce standard ANSI SQL. ## Usage (require '[clojure-sql.core :as s]) (-> (s/table :users) (s/project [:id :username])) ; => ["SELECT \"users\".\"id\", \"users\".\"username\" FROM \"users\""] (-> (s/table {:users :u}) (s/project [:id :username]) (s/rename {:id :uid}) (s/join (-> (s/table {:people :p}) (s/project {:id :pid, :fname :first}) (s/select '(= :first "Henry"))) '(= :uid :pid)) (s/project [:username])) ; => ["SELECT \"u\".\"username\" FROM \"users\" AS \"u\" JOIN \"people\" AS \"p\" ON (\"u\".\"id\" = \"p\".\"id\") WHERE (\"p\".\"fname\" = ?)" "Henry")] (s/use-jdbc! "postgres://user:pass@localhost:5432/db") ; => nil ## License Copyright © 2013 FIXME Distributed under the Eclipse Public License, the same as Clojure.