Skip to main content

Crate keelson_sqlx

Crate keelson_sqlx 

Source
Expand description

The sqlx backend for keelson.

One crate, three drivers behind features — psql, mysql, sqlite — each exposing a Pool (and the transaction machinery via keelson_exec::Begin) that implements keelson_exec::Executor. An application constructs a pool here, in main, and everything above it — generated models, hooks, plain query code — talks keelson_exec traits and never names sqlx.

Per-database drivers, not sqlx::Any: Any erases exactly what docs/type-mappings.md requires kept (native uuid/temporal/decimal parameter binds on the engines that have them).

Each driver module owns two functions that make the type-mappings table executable: bind_value (a total map Value → driver parameter, per the “binds as” column) and decode_value (native row → Value, per the column-type column). The round-trip suites in tests/ are those two functions’ tests.

§Where this sits

The backend half of Layer 2: it implements keelson-exec’s traits and is the only crate in keelson that links a database driver. Application code names it once, in main, to build a pool; everything above talks keelson_exec traits. The statements it runs come from a Layer 1 dialect (keelson-psql, keelson-mysql, keelson-sqlite) or from a generated model. The whole map is the keelson facade crate.

Modules§

mysql
The MySQL driver: Pool implements Executor, Begin, BeginWith and StreamExecutor.
psql
The PostgreSQL driver: Pool implements Executor, Begin, BeginWith and StreamExecutor.
sqlite
The SQLite driver: Pool implements Executor, Begin, BeginWith and StreamExecutor.