summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md27
1 files changed, 19 insertions, 8 deletions
diff --git a/README.md b/README.md
index ad7ae3d..6e82200 100644
--- a/README.md
+++ b/README.md
@@ -4,7 +4,7 @@ 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.
+when a query is to be executed.
`clojure-sql` provides some utility functions beyond strict RA to
allow for data to be inserted, updated and deleted.
@@ -26,28 +26,39 @@ queries to be entirely special-cased per database. By default
(require '[clojure-sql.core :as s])
- (-> (s/table :users)
+ (-> (s/table :users) ;; tables are automatically given internal aliases
(s/project [:id :username]))
- ; => ["SELECT \"users\".\"id\", \"users\".\"username\" FROM \"users\""]
+ ; => ["SELECT \"users1234\".\"id\", \"users1234\".\"username\" FROM \"users\" AS \"users1234\""]
- (-> (s/table {:users :u})
+ (-> (s/table :users)
(s/project [:id :username])
(s/rename {:id :uid})
- (s/join (-> (s/table {:people :p})
+ (s/join (-> (s/table :people)
(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")]
+ ; => ["SELECT \"users1234\".\"username\" FROM \"users\" AS \"users1234\" JOIN \"people\" AS \"people1234\" ON (\"users1234\".\"id\" = \"people1234\".\"id\") WHERE (\"people1234\".\"fname\" = ?)" "Henry")]
+
+
+
+[clojure.java.jdbc][3] support is provided, but must be included explicitly.
(require '[clojure-sql.jdbc :as jdbc])
- ; => nil
+
(jdbc/use-jdbc! "postgres://user:pass@localhost:5432/db")
; => nil
+ (deref (-> (s/table :users)
+ (s/project [:id :username])))
+ ; => [{:id 5, :username "mange"}]
+
+Results are returned from queries in an eager vector.
+
+[3]: https://github.com/clojure/java.jdbc
## License
-Copyright © 2013 FIXME
+Copyright © 2013 Carlo Zancanaro
Distributed under the Eclipse Public License, the same as Clojure.