diff options
-rw-r--r-- | README.md | 20 |
1 files changed, 18 insertions, 2 deletions
@@ -3,8 +3,8 @@ 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 to be executed. +database itself, but can be configured to perform an action 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. @@ -55,6 +55,8 @@ A few more involved query examples: (s/project [:username])) ;; => ["SELECT \"users3430\".\"username\" AS \"username\" FROM (\"users\" AS \"users3430\" INNER JOIN \"people\" AS \"people3432\" ON (\"users3430\".\"id\" = \"people3432\".\"id\")) WHERE (\"people3432\".\"fname\" = ?)" "Henry"] +### clojure.java.jdbc + [`clojure.java.jdbc`][3] support is provided, but must be included explicitly. `clojure-sql` does not depend on `clojure.java.jdbc`. @@ -71,6 +73,20 @@ Results are returned from queries in an eager vector. [3]: https://github.com/clojure/java.jdbc +### Other query executors + +If `clojure.java.jdbc` support is not what you're looking for (or if +you're looking for more control of how `clojure.java.jdbc` is +executed) then you can register a query executor with +`clojure-sql.core/set-query-executor!`. A query executor is a function +which is used to run a query when it is executed. + +When a query is executed the executor is passed two things: the type +of query being executed, and the compiled query (as vector of +`[query-string & query-args]`). The query executor's return value will +be the return value of the associated query function call (`deref`, +`insert!`, `update!` or `delete!`). + ## Generated queries In general, `clojure-sql` will try to avoid creating subqueries. For |