kura_driver_sqlite (kura_sqlite v0.2.5)

View Source

SQLite driver impl using esqlite.

Wraps esqlite3:q/3 and esqlite3:exec/2 behind the kura_driver behaviour so kura code does not need to know which client library is in use.

Result shape

Returns #{rows := Rows, num_rows := N, command := C} to match kura_driver_pgo's shape. Rows are maps keyed by atom column names, making them interchangeable with pgo result rows. command is one of select | insert | update | delete | other derived from the SQL prefix.

Transactions

transaction/4 wraps the fun in BEGIN/COMMIT (or ROLLBACK on throw) using esqlite3:exec/2. The leased connection is stashed in the process dict under kura_sqlite_tx_conn so nested query/5 calls inside the fun route to the same conn.

Caveats (phase 2 skeleton)

  • Type encoding: pass-through. SQLite has type affinity, so booleans arrive as 0/1 rather than true/false. Phase 3 normalizes via the kura type system.
  • query/5 always opens a fresh checkout when not in a transaction; there is no per-query optimization yet.

Summary

Functions

query(PoolMod, Pool, SQL, Params, Opts)

-spec query(module(), atom(), iodata(), [term()], map()) -> dynamic().

query_on(Conn, SQL, Params, Opts)

-spec query_on(esqlite3:esqlite3(), iodata(), [term()], map()) -> dynamic().

transaction(PoolMod, Pool, Fun, Opts)

-spec transaction(module(), atom(), fun(() -> term()), map()) -> term().