No description
Find a file
cel 69045ec556
Some checks failed
Test / test_bundled (ubuntu-latest) (push) Has been cancelled
Test / test_bundled_sqlite3mc (ubuntu-latest) (push) Has been cancelled
Test / test_diesel (push) Has been cancelled
Test / test_rusqlite (push) Has been cancelled
Test / test_clippy (push) Has been cancelled
Test / test_implement_a_vfs (push) Has been cancelled
Test / test_fmt (push) Has been cancelled
Test / test_atomics (ubuntu-latest) (push) Has been cancelled
Test / test_msrv (ubuntu-latest) (push) Has been cancelled
Test / test_nodejs (ubuntu-latest) (push) Has been cancelled
Test / test_sqlite_wasm_vec (ubuntu-latest) (push) Has been cancelled
Test / test_sqlite_wasm_vfs (ubuntu-latest) (push) Has been cancelled
Test / test_sqlite_wasm_tests (ubuntu-latest) (push) Has been cancelled
Test / test_vfs_native (ubuntu-latest) (push) Has been cancelled
Pass cargo target features to cc
2026-06-10 19:54:51 +02:00
.cargo Move sqlite-wasm-rs to the root (#112) 2025-09-27 22:13:00 +08:00
.github/workflows Make crates compile on 1.81.0 (#172) 2026-05-19 19:32:03 +08:00
.vscode Update sqlite-wasm-vec documentation (#163) 2025-12-21 17:00:13 +08:00
crates Bump rsqlite-vfs (#174) 2026-05-19 19:46:44 +08:00
examples Remove the dependency of sqlite-wasm-vfs on sqlite-wasm-rs (#165) 2025-12-21 20:14:13 +08:00
extensions/sqlite-vec Minimal cc version (#175) 2026-05-23 14:01:57 +08:00
script Make crates compile on 1.81.0 (#172) 2026-05-19 19:32:03 +08:00
shim Remove wsqlite3-sys (#166) 2025-12-21 20:55:11 +08:00
sqlite3 Prepare v0.5.3 release (#171) 2026-04-19 02:40:55 +08:00
sqlite3mc Prepare v0.5.3 release (#171) 2026-04-19 02:40:55 +08:00
src Make crates compile on 1.81.0 (#172) 2026-05-19 19:32:03 +08:00
tests Improve comments and build flags (#167) 2026-01-17 19:09:10 +08:00
.gitignore Support multithreading 2025-01-23 02:18:47 +08:00
build.rs Pass cargo target features to cc 2026-06-10 19:54:51 +02:00
Cargo.toml Prepare v0.5.5 release 2026-05-25 11:00:49 +08:00
CHANGELOG.md Prepare v0.5.5 release 2026-05-25 11:00:49 +08:00
LICENSE Move LICENSE 2025-01-23 02:18:47 +08:00
README.md Make crates compile on 1.81.0 (#172) 2026-05-19 19:32:03 +08:00

Crates.io

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]
# It requires sqlite-wasm-rs 0.5.2 or higher to be used,
# for version 0.5.1, use version 0.1 instead.
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:

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.81.0.

Extensions

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.