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.
(bind-one! stmt idx v)Bind one positional parameter (1-based); public for statement layers layered on top (the next.jdbc adapter).
Bind one positional parameter (1-based); public for statement layers layered on top (the next.jdbc adapter).
(changes db)Rows changed by the most recent statement on this connection - executeUpdate's return value.
Rows changed by the most recent statement on this connection - executeUpdate's return value.
(column-count stmt)Number of columns in the current row set.
Number of columns in the current row set.
(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.
(column-value stmt i)One column of the current row by 0-based index, type-dispatched; public for statement layers layered on top.
One column of the current row by 0-based index, type-dispatched; public for statement layers layered on top.
(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.
(reset-stmt stmt)Reset a statement for reuse; public for statement layers.
Reset a statement for reuse; public for statement layers.
(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.
(step-once! stmt)One sqlite3_step; raw result code (100 row, 101 done, else error).
One sqlite3_step; raw result code (100 row, 101 done, else error).
(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. A null value pointer (VIRTUAL generated columns in preupdate rows: not stored, not computable inside the hook) reads as nil.
One sqlite3_value to a Clojure value, per its type code. Must run while the value is alive - inside a preupdate callback. A null value pointer (VIRTUAL generated columns in preupdate rows: not stored, not computable inside the hook) reads as nil.
(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 |