Skip to main content

Crate sqlrite

Crate sqlrite 

Source
Expand description

SQLRite — a small SQLite clone written in Rust, as a library.

The REPL binary (src/main.rs) uses this library. The Tauri desktop app under desktop/src-tauri/ uses it too. Future consumers — a Connection API split, a WASM build, a C FFI shim — all grow out of this same surface.

Scope right now. The library surfaces two layers:

1. High-level public API (Phase 5a). The shape most callers want — stable, documented, and the same surface that the C FFI shim (Phase 5b) and every language SDK (Python / Node / Go / WASM) binds against:

  • Connection — open a file, in-memory DB, or read-only view
  • Statement — prepared SQL with typed row iteration
  • Rows / Row / OwnedRow — streaming typed result rows
  • FromValue — pluggable row-to-Rust conversion (i64, f64, String, bool, Option<T>, plus raw Value)
use sqlrite::Connection;
let mut conn = Connection::open("foo.sqlrite")?;
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, name): (i64, String) = (row.get(0)?, row.get(1)?);
    println!("{id}: {name}");
}

2. Lower-level engine surface. Accessible via sqlrite::sql::… for the REPL, the Tauri desktop app, and the engine’s own tests:

Lower-level modules (sql::pager, sql::executor, etc.) remain accessible through sqlrite::sql::… for tests and tooling, but aren’t considered public API — their shapes will change as Phase 4 (WAL + locks) and Phase 5 (cursor / lazy-load) land.

Re-exports§

pub use connection::Connection;
pub use connection::FromValue;
pub use connection::OwnedRow;
pub use connection::Row;
pub use connection::Rows;
pub use connection::Statement;
pub use sql::db::table::Value;
pub use error::Result;
pub use error::SQLRiteError;
pub use sql::db::database::Database;
pub use sql::pager::AccessMode;
pub use sql::pager::MASTER_TABLE_NAME;
pub use sql::pager::open_database;
pub use sql::pager::open_database_read_only;
pub use sql::pager::open_database_with_mode;
pub use sql::pager::save_database;
pub use sql::process_command;
pub use ::sqlparser;

Modules§

connection
Public Connection / Statement / Rows / Row API (Phase 5a).
error
sql