Skip to main content

Crate oxisql_sqlite_compat

Crate oxisql_sqlite_compat 

Source
Expand description

oxisql-sqlite-compat — Pure-Rust SQLite-compatible backend for OxiSQL.

Wraps oxisqlite — a C-free fork of Limbo 0.0.22 with all C/C++ dependencies stripped — and implements Connection so that any OxiSQL consumer can use SQLite without linking libsqlite3 or any C/C++ dependency.

§Quick start

use oxisql_sqlite_compat::SqliteConnection;
use oxisql_core::Connection;

// In-memory database (destroyed when the connection is dropped).
let conn = SqliteConnection::open_memory().await?;

conn.execute("CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT)", &[]).await?;
conn.execute("INSERT INTO users VALUES ($1, $2)", &[&1i64, &"Alice"]).await?;

let rows = conn.query("SELECT id, name FROM users", &[]).await?;
assert_eq!(rows.len(), 1);

§File-backed database

use oxisql_sqlite_compat::SqliteConnection;

let conn = SqliteConnection::open(path.to_str().unwrap()).await?;

§Limbo version caveats (0.0.22)

  • Affected-row count: Limbo’s execute() returns a status code, not an affected-row count. This crate issues SELECT changes() after each DML to retrieve the count, which adds one round-trip per write operation.
  • Positional parameters: Limbo only supports ? placeholders. OxiSQL uses $1, $2, … — this crate performs a quote-aware rewrite before each statement is prepared.
  • Named parameters: Not supported (upstream limbo 0.0.22 limitation). Calling code should use positional parameters only.
  • Prepared-statement caching: limbo 0.0.22 / oxisqlite does not cache compiled bytecode. The PreparedStatement wrapper re-prepares on every call.
  • Savepoints: Not supported. Calling savepoint / rollback_to_savepoint / release_savepoint returns OxiSqlError::Other.

Re-exports§

pub use connection::SqliteConnection;
pub use error::SqliteCompatError;

Modules§

connection
SqliteConnection — Limbo-backed implementation of oxisql_core::Connection.
error
Error types for the SQLite-compat (Limbo) backend.
types
Value conversions between limbo and oxisql_core.