Expand description
Public Connection / Statement / Rows / Row API (Phase 5a).
This is the stable surface external consumers bind against — Rust
callers use it directly, language SDKs (Python, Node.js, Go) bind
against the C FFI wrapper over these same types in Phase 5b, and
the WASM build in Phase 5g re-exposes them via wasm-bindgen.
The shape mirrors rusqlite / Python’s sqlite3 so users
familiar with either can pick it up immediately:
use sqlrite::Connection;
let mut conn = Connection::open("foo.sqlrite")?;
conn.execute("CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT)")?;
conn.execute("INSERT INTO users (name) VALUES ('alice')")?;
let mut stmt = conn.prepare("SELECT id, name FROM users")?;
let mut rows = stmt.query()?;
while let Some(row) = rows.next()? {
let id: i64 = row.get(0)?;
let name: String = row.get(1)?;
println!("{id}: {name}");
}Relationship to the internal engine. A Connection owns a
Database (which owns a Pager for file-backed connections).
execute and query go through the same process_command
pipeline the REPL uses, just with typed row return instead of
pre-rendered tables. The internal Database / Pager stay
accessible via sqlrite::sql::... for the engine’s own tests
and for the desktop app — but those paths aren’t considered
stable API.
Structs§
- Connection
- A handle to a SQLRite database. Opens a file or an in-memory DB;
drop it to close. Every mutating statement auto-saves (except inside
an explicit
BEGIN/COMMITblock — see Transactions). - Owned
Row - A row detached from the
Rowsiterator — owns its data, no borrow ties it to the parent iterator. - Row
- A single row borrowed from a
Rowsiterator. Lives only as long as the iterator; callRow::to_owned_rowto detach it if you need to keep it past the nextnext()call. - Rows
- Iterator of typed
Rowvalues produced by aSELECTquery. - Statement
- A prepared statement bound to a specific connection lifetime. Today this is a thin wrapper around the raw SQL; Phase 5’s cursor work will grow it into a real prepared-plan cache.