Thin, idiomatic Clojure over the org.sqlite.jni C-style binding.
This is the only namespace that touches the JNI classes (besides natives' loader), so upstream's experimental-API churn stays behind one seam. Everything here maps one C call to one Clojure function, converts values per column type, and turns non-OK result codes into ex-info carrying sqlite3_errmsg - the C layer never throws on its own.
Resource discipline follows the binding's golden rule: statements are finalized (with-stmt) and databases closed (close!) explicitly; the GC never frees native resources.
Thin, idiomatic Clojure over the org.sqlite.jni C-style binding. This is the only namespace that touches the JNI classes (besides natives' loader), so upstream's experimental-API churn stays behind one seam. Everything here maps one C call to one Clojure function, converts values per column type, and turns non-OK result codes into ex-info carrying sqlite3_errmsg - the C layer never throws on its own. Resource discipline follows the binding's golden rule: statements are finalized (with-stmt) and databases closed (close!) explicitly; the GC never frees native resources.
(bind-all! stmt params)Bind positional parameters left to right, 1-based.
Bind positional parameters left to right, 1-based.
(column-names db table)Declared column names of a table, from a zero-row select - the engine's column-name cache for translating positional preupdate values into names.
Declared column names of a table, from a zero-row select - the engine's column-name cache for translating positional preupdate values into names.
(eqp-tables db sql)Normalised table set the planner reports reading - sqldeps' sound floor. Runs unbound: the plan does not depend on parameter values.
Normalised table set the planner reports reading - sqldeps' sound floor. Runs unbound: the plan does not depend on parameter values.
(exec! db sql)(exec! db sql params)Run one write statement (no result rows expected). Exactly one statement: multi-statement strings are rejected by the engine above this layer.
Run one write statement (no result rows expected). Exactly one statement: multi-statement strings are rejected by the engine above this layer.
(open)(open uri)Open a database; no argument means in-memory. URIs need no flags - SQLITE_OPEN_URI is always set, matching how users expect file:...?mode=memory&cache=shared spellings to behave.
Open a database; no argument means in-memory. URIs need no flags - SQLITE_OPEN_URI is always set, matching how users expect file:...?mode=memory&cache=shared spellings to behave.
(prepare db sql)Compile one statement. Whitespace-only SQL is an error, not a nil statement - callers always want a real statement or an exception.
Compile one statement. Whitespace-only SQL is an error, not a nil statement - callers always want a real statement or an exception.
(query-all db sql)(query-all db sql params)Run one statement, realizing all rows as maps keyed by column name in declaration order.
Run one statement, realizing all rows as maps keyed by column name in declaration order.
(run-stmt! stmt params)Bind, run to completion and reset a prepared statement for reuse - the engine's recompute path over cached statements.
Bind, run to completion and reset a prepared statement for reuse - the engine's recompute path over cached statements.
(step-all stmt)Step a bound statement to completion; returns nothing. The engine's write path - queries use query-all.
Step a bound statement to completion; returns nothing. The engine's write path - queries use query-all.
(value->clj v)One sqlite3_value to a Clojure value, per its type code. Must run while the value is alive - inside a preupdate callback.
One sqlite3_value to a Clojure value, per its type code. Must run while the value is alive - inside a preupdate callback.
(with-db [db db-or-uri] & body)Evaluate body with a database - an open handle passed through, a URI string opened - closed afterwards when we opened it.
Evaluate body with a database - an open handle passed through, a URI string opened - closed afterwards when we opened it.
(with-stmt [stmt prepare-expr] & body)Evaluate body with a compiled statement, finalized afterwards.
Evaluate body with a compiled statement, finalized afterwards.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |