From d70e99185025eeef545248321c04d885aa6a38c2 Mon Sep 17 00:00:00 2001 From: Carlo Zancanaro Date: Tue, 14 May 2013 11:12:05 +1000 Subject: Most of the RA stuff works now. Need to fix up the compilation to return a query ready for value substitution by the jdbc stuff, or something (rather than embedding parameters in the query). Also need to add insert!, update! and delete! functions. --- README.md | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) (limited to 'README.md') diff --git a/README.md b/README.md index 7b454a1..5e58b6b 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,36 @@ # clojure-sql -A Clojure library designed to ... well, that part is up to you. +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` 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 ## Usage -FIXME + (require '[clojure.sql :as s]) + + (-> (s/table :users) + (s/project [:id :username]) + deref) + ; => "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]) + deref) + ; => "SELECT \"u\".\"username\" FROM \"users\" AS \"u\" JOIN \"people\" AS \"p\" ON (\"u\".\"id\" = \"p\".\"id\") WHERE (\"p\".\"fname\" = 'Henry')" ## License -- cgit v1.2.3