wasm32-unknown-unknown bindings to the libsqlite3 library.
[dependencies]
sqlite-wasm-rs = { version = "0.6", features = ["wasm-bindgen"] }[dependencies]
# Encryption is supported by SQLite3MultipleCiphers
# See <https://utelle.github.io/SQLite3MultipleCiphers>
sqlite-wasm-rs = { version = "0.6", features = ["wasm-bindgen", "sqlite3mc"] }use sqlite_wasm_rs as ffi;
fn open_db() {
// open with memory vfs
let mut db = std::ptr::null_mut();
let ret = unsafe {
ffi::sqlite3_open_v2(
c"mem.db".as_ptr().cast(),
&mut db as *mut _,
ffi::SQLITE_OPEN_READWRITE | ffi::SQLITE_OPEN_CREATE,
std::ptr::null()
)
};
assert_eq!(ffi::SQLITE_OK, ret);
assert_eq!(unsafe { ffi::sqlite3_close(db) }, ffi::SQLITE_OK);
}[dependencies]
sqlite-wasm-vfs = { version = "0.3", features = ["sahpool"] }The following vfs have been implemented:
memory: as the default vfs, no additional conditions are required, store the database in memory.sahpool: ported from sqlite-wasm, store the database in opfs.
Here is an example showing how to implement a simple in-memory VFS, see implement-a-vfs example.
cargo run -p rsqlite-vfs --example implement-a-vfsMultithreading is not supported, SQLite is compiled with -DSQLITE_THREADSAFE=0.
No features are enabled by default, provide your own host functions. See JS Host or C Host example.
Point SQLITE_WASM_RS_SOURCE_DIR to your sqlite3.c/.h files (sqlite3mc_amalgamation.c/.h for sqlite3mc):
SQLITE_WASM_RS_SOURCE_DIR=/path/to/sqlite cargo build --target wasm32-unknown-unknown --features bindgenThe minimal officially supported rustc version is 1.81.0.
| Extension | About |
|---|---|
| sqlite-vec | A vector search SQLite extension that runs anywhere! |
Contributions are welcome!
diesel: A safe, extensible ORM and Query Builder for Rust.rusqlite: Ergonomic bindings to SQLite for Rust.sqlite-wasm: SQLite Wasm conveniently wrapped as an ES Module.sqlite-web-rs: A SQLite WebAssembly backend for Diesel.wa-sqlite: WebAssembly SQLite with support for browser storage extensions.SQLite3MultipleCiphers: SQLite3 encryption extension with support for multiple ciphers.
- moli - Best browser for AI Agent, written in pure Rust.