docs.rs failed to build sqlite-wasm-0.1.1
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
SQLite WASM
A high-performance SQLite wrapper for WebAssembly with OPFS support
Zero-cost abstractions โข Type-safe API โข Persistent storage โข Single-threaded by design
โจ Features
| Icon | Feature | Description |
|---|---|---|
| ๐ | Zero-cost abstractions | Worker management with OnceLock and atomic counters |
| ๐ | OPFS persistence | Databases survive page reloads and browser restarts |
| ๐งต | Web Worker | Database operations run in a separate thread |
| ๐ฆ | Auto-minification | JS glue code automatically minified (Brotli/Gzip) |
| ๐ | COOP/COEP Headers | Proper headers for SharedArrayBuffer support |
| ๐ฏ | Type Safe | Strongly typed Rust API with proper error handling |
| ๐ | Async/Await | Promise-based API for JavaScript |
| โก | Atomic operations | Lock-free message passing with AtomicU32 |
๐ Test It Live
๐ Try SQLite Studio Online
No installation needed. Opens directly in your browser.
๐ฆ Installation
Add to your Cargo.toml:
[]
= "0.1"
Or via CLI:
๐จ Building
๐๏ธ Architecture
โโโโโโโโโโโโโโโโโโโ
โ Your App โ
โ (Rust/JS) โ
โโโโโโโโโโฌโโโโโโโโโ
โ
โโโโโโโโโโผโโโโโโโโโ
โ sqlite-wasm โ
โ โโโโโโโโโโโโโโโ
โ โ Worker โโ โโ Singleton, auto-managed
โ โ Manager โโ
โ โโโโโโโโโโโโโโโ
โ โโโโโโโโโโโโโโโ
โ โ Message โโ โโ Atomic counters, oneshot channels
โ โ Passing โโ
โ โโโโโโโโโโโโโโโ
โ โโโโโโโโโโโโโโโ
โ โ OPFS โโ โโ Persistent, high-performance
โ โ Storage โโ
โ โโโโโโโโโโโโโโโ
โโโโโโโโโโฌโโโโโโโโโ
โ
โโโโโโโโโโผโโโโโโโโโ
โ SQLite Worker โ
โ (JavaScript) โ
โโโโโโโโโโโโโโโโโโโ
API Reference
| Function | Description |
|---|---|
autostart(path) |
Initializes the SQLite worker (call once) |
open(name) |
Opens or creates a database |
exec(sql, params) |
Executes SQL without returning rows |
query(sql, params) |
Executes SELECT and returns rows |
close() |
Closes the current database |
is_open() |
Checks if a database is open |
db_id() |
Returns current database ID (debug) |
๐ฆ Rust Usage
Quick Start
use ;
pub async
๐ JavaScript Usage
After initialization, the global wasm object is available with all methods.
Quick Start
import init from './pkg/sqlite_wasm.js';
.;
JavaScript API
| Method | Description | Example |
|---|---|---|
autostart(path) |
Initializes worker | await wasm.autostart('/sqlite.org/sqlite3-worker1.js') |
open(name) |
Opens/creates database | await wasm.open('mydb.sqlite3') |
exec(sql, params) |
Executes SQL | await wasm.exec("INSERT INTO users VALUES (?)", ["Joรฃo"]) |
query(sql, params) |
Runs SELECT | const res = await wasm.query("SELECT * FROM users", []) |
close() |
Closes database | await wasm.close() |
๐ Browser Requirements
- WebAssembly support
- Web Workers
- OPFS (Origin Private File System)
- COOP/COEP headers (Cross-Origin Isolation)
Recommended: Latest Chrome, Edge, or other Chromium-based browsers.
๐ License
MIT ยฉ adorno-dev
Built with ๐ฆ and โค๏ธ for maximum performance
Made in Rust ยท Runs in Browser ยท Powered by SQLite