SQLite driver for moondb/moonorm — native FFI, amalgamation vendored here (isolated).
Dependencies
The package name is hyphenated, so import it under an alias in moon.pkg.json — {"path": "Lfan-ke/moon-sqlite", "alias": "sqlite"} — and reach it as @sqlite (as below). Value constructors come from @moondb (moon add Lfan-ke/moondb).
// native target only — this package links the vendored amalgamation.
fn demo() -> Unit raise @moondb.DbError {
let db = @sqlite.SqliteDriver::open(":memory:") // implements @moondb.Driver
db.execute("CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT, age INTEGER)", [])
|> ignore
// Bound params map to SQLite storage classes — never spliced into the SQL text.
db.execute("INSERT INTO users (name, age) VALUES (?, ?)", [
@moondb.Text("alice"), @moondb.Int(30),
]) |> ignore
// Result columns decode back into @moondb.Value by their runtime type.
let rows = db.query("SELECT name, age FROM users WHERE age > ?", [@moondb.Int(18)])
let _ = rows[0].text(0) // "alice"
let _ = rows[0].int(1) // 30
db.close()
}let sess = @moonorm.Session::new(@sqlite.SqliteDriver::open("app.db"))
sess.add(@moonorm.insert("users").set("name", @moondb.Text("bob"))) |> ignore
let rows = sess.fetch(@moonorm.select("users").where_("name", "=", @moondb.Text("bob")))type SqliteCursorimpl Cursor for SqliteCursorpub struct SqliteDriver {
handle : Int64
closed : Bool
}impl Driver for SqliteDriverSQLite driver for moondb/moonorm — native FFI, amalgamation vendored here (isolated).
Dependencies