27 releases
| 0.5.2 | Jan 17, 2026 |
|---|---|
| 0.5.1 | Dec 17, 2025 |
| 0.4.8 | Nov 30, 2025 |
| 0.4.2 | Jul 20, 2025 |
| 0.1.0 |
|
#50 in WebAssembly
154,097 downloads per month
Used in 503 crates
(6 directly)
23MB
424K
SLoC
wasm32-unknown-unknown bindings to the libsqlite3 library.
Usage
[dependencies]
sqlite-wasm-rs = "0.5"
[dependencies]
# Encryption is supported by SQLite3MultipleCiphers
# See <https://utelle.github.io/SQLite3MultipleCiphers>
sqlite-wasm-rs = { version = "0.5", features = ["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);
}
About VFS
[dependencies]
sqlite-wasm-vfs = "0.2"
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.relaxed-idb: store the database in blocks in indexed db.
VFS Comparison
| MemoryVFS | SyncAccessHandlePoolVFS | RelaxedIdbVFS | |
|---|---|---|---|
| Storage | RAM | OPFS | IndexedDB |
| Contexts | All | Dedicated Worker | All |
| Multiple connections | ❌ | ❌ | ❌ |
| Full durability | ✅ | ✅ | ❌ |
| Relaxed durability | ❌ | ❌ | ✅ |
| Multi-database transactions | ✅ | ✅ | ✅ |
| No COOP/COEP requirements | ✅ | ✅ | ✅ |
How to implement a VFS
Here is an example showing how to use sqlite-wasm-rs to implement a simple in-memory VFS, see implement-a-vfs example.
About multithreading
This library is not thread-safe:
JsValueis not cross-threaded, see https://github.com/rustwasm/wasm-bindgen/pull/955 for details.- sqlite is compiled with
-DSQLITE_THREADSAFE=0.
Use prebuild libsqlite3.a
We provide the ability to use prebuild libsqlite3.a, cargo provides a links field that can be used to specify which library to link to. With the help of overriding build scripts, you can overriding its configuration in your crate and link sqlite to your prebuild libsqlite3.a.
More see use-prebuild-lib example.
Minimum supported Rust version (MSRV)
The minimal officially supported rustc version is 1.82.0.
Extensions
| Extension | About |
|---|---|
| sqlite-vec | A vector search SQLite extension that runs anywhere! |
Contributions are welcome!
Related Project
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.