Embedded SQL database with vector search — Rust + WASM. The "SQLite of AI."
PledgeDB is an embedded SQL database built in Rust with first-class vector search support. It runs natively on servers, in the browser via WebAssembly, and on mobile devices. No server required.
Every AI application needs three things:
- Structured data storage (SQL tables, queries, joins)
- Vector search (semantic similarity for RAG, recommendations, search)
- Local/edge deployment (privacy, latency, offline-first)
Today, you need three separate tools for this: SQLite + a vector DB (Pinecone/Qdrant) + a sync layer. PledgeDB replaces all three with a single embedded database.
- Full SQL — CREATE, INSERT, SELECT, UPDATE, DELETE, WHERE, ORDER BY, LIMIT, OFFSET
- JOINs — INNER, LEFT, RIGHT joins with ON conditions
- Aggregations — COUNT, SUM, AVG, MIN, MAX with GROUP BY
- Transactions — BEGIN, COMMIT, ROLLBACK with undo log
- Crash recovery — WAL (write-ahead log) with automatic replay on reopen
- Vector search — HNSW index for sub-ms similarity search on 100K+ vectors
- Distance metrics — L2 (Euclidean), Cosine, Dot product
- Full-text search — BM25 scoring with inverted index and MATCH() function
- Hybrid search — Combined vector + FTS score fusion in a single query
- Query optimizer — Logical plan IR, statistics, cost model, predicate pushdown, join reordering
- WASM-native — Purpose-built for browser, not C-compiled-through-Emscripten
- Small binary — ~500KB WASM target (vs 2-3MB for SQLite/DuckDB WASM)
- Multi-platform — Rust, Python, JavaScript, React Native
- Browser persistence — OPFS + IndexedDB backends (planned)
- Rust core — Memory safe, no segfaults, no undefined behavior
use pledgedb_core::Database;
let mut db = Database::open_or_create("mydb.pldb")?;
// Create a table with a vector column
db.execute("CREATE TABLE documents (
id INTEGER PRIMARY KEY,
title TEXT NOT NULL,
embedding VECTOR(128)
)")?;
// Insert data
db.execute("INSERT INTO documents (title, embedding) VALUES ('Hello', '[0.1, 0.2, ...]')")?;
// Query with JOINs and aggregations
db.execute("CREATE TABLE tags (id INTEGER PRIMARY KEY, doc_id INTEGER, name TEXT)")?;
db.execute("INSERT INTO tags (doc_id, name) VALUES (1, 'rust')")?;
let result = db.execute("
SELECT d.title, COUNT(t.id) as tag_count
FROM documents d
LEFT JOIN tags t ON d.id = t.doc_id
GROUP BY d.title
")?;
// Transactions with crash recovery
db.enable_wal("mydb.pldb")?;
db.execute("BEGIN")?;
db.execute("INSERT INTO documents (title) VALUES ('Transaction safe')")?;
db.execute("COMMIT")?;
// Data survives crashes — WAL replays committed transactions on reopen# Initialize a database
pledgedb init --file mydb.pldb
# Start interactive shell
pledgedb shell --file mydb.pldb
# Execute a statement
pledgedb exec --file mydb.pldb "SELECT * FROM users"
# List tables
pledgedb tables --file mydb.pldbimport { PledgeDB } from "pledgedb-wasm";
const db = new PledgeDB();
await db.init();
await db.exec("CREATE TABLE docs (id INTEGER PRIMARY KEY, vec VECTOR(128))");
const result = await db.exec("SELECT * FROM docs");-- Standard SQL
CREATE TABLE articles (
id INTEGER PRIMARY KEY,
title TEXT NOT NULL,
content TEXT,
embedding VECTOR(384)
);
-- Insert with vector
INSERT INTO articles (title, content, embedding)
VALUES ('Rust Guide', 'Learn Rust...', '[0.1, 0.2, ...]');
-- Vector similarity search (find 5 most similar articles)
SELECT * FROM articles
ORDER BY embedding <-> '[0.15, 0.25, ...]'
LIMIT 5;
-- Create HNSW vector index
CREATE VECTOR INDEX idx_articles_embedding
ON articles(embedding) TYPE hnsw (m=16, ef_construction=200);pledgedb/
├── crates/
│ ├── pledgedb-core/ # SQL parser, storage engine, WAL, query executor, optimizer
│ ├── pledgedb-vector/ # HNSW index, distance metrics (SIMD)
│ ├── pledgedb-wasm/ # WASM bindings (browser/edge) with OPFS/IndexedDB persistence
│ ├── pledgedb-python/ # Python bindings (PyO3)
│ ├── pledgedb-react-native/ # React Native bindings (AsyncStorage persistence)
│ ├── pledgedb-workers/ # Cloudflare Workers bindings (KV/R2 persistence)
│ └── pledgedb-cli/ # Command-line tool
├── Cargo.toml # Workspace config
├── ARCHITECTURE.md # Technical documentation
├── COMPARISON.md # Competitor analysis
└── README.md # This file
| Crate | Description |
|---|---|
pledgedb-core |
SQL parser (sqlparser-rs), page-based storage, B-tree, WAL crash recovery, query executor with JOINs and aggregations, query optimizer (plan IR, statistics, cost model) |
pledgedb-vector |
HNSW index, SIMD-accelerated distance metrics (L2, Cosine, Dot), quantization |
pledgedb-wasm |
WebAssembly bindings with OPFS/IndexedDB persistence, async save/load |
pledgedb-python |
Python bindings via PyO3 (in-memory + file-based) |
pledgedb-react-native |
React Native bindings with AsyncStorage persistence |
pledgedb-workers |
Cloudflare Workers bindings with KV/R2 persistence |
pledgedb-cli |
Interactive SQL shell and command-line tool |
- SQL parser (CREATE, INSERT, SELECT, UPDATE, DELETE, DROP)
- Page-based storage engine with B-tree
- Query executor with WHERE, ORDER BY, LIMIT, OFFSET
- HNSW vector index with SIMD distance metrics
- CLI tool with interactive shell
- WAL (write-ahead log) for crash recovery
- JOINs (INNER, LEFT, RIGHT) with ON conditions
- Aggregations (COUNT, SUM, AVG, MIN, MAX, GROUP BY)
- Transactions (BEGIN, COMMIT, ROLLBACK) with undo log
- MVCC concurrency control
- Vector search in SQL (
ORDER BY embedding <-> query LIMIT k) - CREATE VECTOR INDEX syntax
- Full-text search (BM25)
- Hybrid search (vector + FTS + filters)
- Quantization (Int8, Binary)
- WASM build with OPFS persistence (IndexedDB fallback)
- JavaScript/TypeScript bindings
- Python bindings (PyO3)
- React Native bindings (AsyncStorage persistence)
- Cloudflare Workers support (KV/R2 persistence)
- Query optimizer (cost-based — plan IR, statistics, predicate pushdown, join reordering)
- Prepared statements (? and $N parameter binding)
- Connection pooling
- Replication
- Backup/restore
- Schema migrations
MIT