moon-sqlite
The native SQLite driver for the moondb interface — it implements @moondb.Driver over the vendored SQLite amalgamation, so every moondb-based query layer (moonorm and friends) runs on real SQLite. The only C-touching package in the stack.
moon add Lfan-ke/moon-sqlite✶ The contract at a glance
let db = @sqlite.SqliteDriver::open(":memory:") // impl @moondb.Driver db.execute("INSERT INTO users (name, age) VALUES (?, ?)", [Text("alice"), Int(30)]) let rows = db.query("SELECT name FROM users WHERE age > ?", [Int(18)]) rows[0].text(0) // "alice" // params are bound out-of-band by SQLite, never spliced => injection-safe to the wire.
§SQLite driver
SqliteDriver: a real connection to a real SQLite database over the vendored amalgamation. It implements @moondb.Driver (execute / query / begin / commit / rollback / close), so any moondb-based query layer - moonorm's Session, a hand-written statement - runs on real SQLite. Bound params map to SQLite's storage classes; result columns decode back into @moondb.Value by type.
struct SqliteDriver
A live connection to a SQLite database. Open it with SqliteDriver::open; it implements @moondb.Driver, so a moondb query layer can drive it directly. The opaque sqlite3* is carried as its pointer bits in handle.
fn SqliteDriver::open(path : String) -> SqliteDriver raise @moondb.DbError
Open (or create) the database at path. Use ":memory:" for a private in-memory database. Raises @moondb.ConnectError if the file cannot be opened.
fn SqliteDriver::is_closed(self : SqliteDriver) -> Bool
Whether close has been called. Once closed, every statement raises @moondb.Closed rather than touching the freed sqlite3*.
fn SqliteDriver::exec_script( self : SqliteDriver, script : String) -> Unit raise @moondb.DbError
Run a semicolon-separated script (e.g. a schema DDL block) in one call. Unlike execute, this uses SQLite's multi-statement exec path and binds no parameters. Raises @moondb.QueryError with SQLite's message on failure.
impl @moondb.Driver for SqliteDriver with fn execute(self, sql, params)
impl @moondb.Driver for SqliteDriver with fn query(self, sql, params)
impl @moondb.Driver for SqliteDriver with fn begin(self)
impl @moondb.Driver for SqliteDriver with fn commit(self)
impl @moondb.Driver for SqliteDriver with fn rollback(self)
impl @moondb.Driver for SqliteDriver with fn close(self)