minisqlite is a complete reimplementation of SQLite in Rust, featuring its SQL dialect, query planner, executor, transactions, and on-disk file format, enabling full read/write compatibility with SQLite databases.

Stars

241

7-day growth

+100

Forks

23

Open issues

1

License

No data

Last updated

2026-07-17

AI repository intelligence
FR-AI / ANALYSIS

Why it is worth attention

This project stands out for its thoroughness—200,000 lines of Rust across 14 crates, 5,650 tests, zero unsafe in library code—and its deliberate minimal public API (one type, four methods), making it a safe, well-architected alternative to binding SQLite from C.

Who it is for

  • Rust developers who need an embedded SQL database without FFI dependencies
  • Database engineers or students studying query planning, execution, and storage internals
  • Systems programmers seeking a small, safe, and fully compatible SQLite reimplementation
  • Open-source contributors interested in a well-structured, modifiable database kernel

Use cases

  • Embedded database for Rust applications (e.g., mobile, desktop, or server tools) that must read and write SQLite files
  • Replacing sqlite3 bindings in Rust projects to eliminate C dependencies and reduce build complexity
  • Educational sandbox for learning how a relational database engine works, from parsing to b-trees and WAL recovery
  • Cross-platform data exchange using the ubiquitous SQLite file format with a pure Rust stack

Strengths

  • Full SQLite 3 dialect support: queries, DML, DDL, constraints, triggers, window functions, JSON, and PRAGMAs
  • Comprehensive test suite (5,650 tests) with conformance tests transcribed from SQLite documentation and byte-level fixture tests for format correctness
  • No unsafe code in library crates, ensuring memory safety without relying on external C libraries
  • Modular architecture with 14 crates, enforced seams, and clear dependency direction, making the codebase easy to navigate and modify

Considerations

  • No prepared statements, CLI, or C API—only a small Rust public API with execute/query methods
  • Concurrency limited to in-process multiple connections; no cross-process file locking (no -shm protocol), so not suitable for multi-process access
  • Query optimizer lacks statistics-based costing; it uses structural rules only (e.g., uniqueness, prefix length), which may lead to suboptimal plans for complex queries

README quick start

minisqlite

A reimplementation of SQLite in Rust: the SQL dialect, the query planner and executor, transactions, and the storage engine, down to the official on-disk file format. It opens database files that sqlite3 wrote and writes files that sqlite3 reads back.

It is a library with a deliberately small surface: one type, four methods. The implementation is about 200,000 lines of Rust across 14 crates, with 5,650 tests, one external dependency (elsa, for the page cache), and no unsafe in library code.

use minisqlite::{Connection, Value};
use std::path::Path;

let mut db = Connection::open(Path::new("app.db"))?; // or Connection::open_in_memory()

db.execute(
    "CREATE TABLE users(id INTEGER PRIMARY KEY, name TEXT NOT NULL);
     INSERT INTO users(name) VALUES ('alice'), ('bob');",
)?;

let r = db.query("SELECT id, name FROM users WHERE name LIKE 'a%'")?;
assert_eq!(r.columns, ["id", "name"]);
assert!(matches!(&r.rows[0][1], Value::Text(name) if name == "alice"));

That is the whole public API: Connection::{open, open_in_memory, execute, query}, plus the re-exported Value, Row, QueryResult, and Error types. execute runs any number of ;-separated statements; query returns the last statement's result set. Value has exactly the five SQLite storage classes: Null, Integer(i64), Real(f64), Text(String), Blob(Vec). There is no CLI, no C API, and no prepared-statement interface.

Build and test with a recent stable toolchain (the workspace uses edition 2024):

cargo build --workspace
cargo test  --workspace    # 5,650 tests, about 90 s
cargo bench                # scalability + durability measurement harness

File compatibility

The on-disk format is SQLite's format 3, in both directions:

$ sqlite3 app.db "CREATE TABLE t(x); INSERT INTO t VALUES ('written by sqlite3')"
$ # ... open app.db with minisqlite, read that row, INSERT 'written by minisqlite' ...
$ sqlite3 app.db "SELECT x FROM t; PRAGMA integrity_check"
written by sqlite3
written by minisqlite
ok

This includes the hard cases: WAL databases with a live -wal file, UTF-16LE and UTF-16BE text encodings, auto-vacuum databases with pointer-map pages, overflow chains, freelists, page sizes from 512 to 65536 bytes, and databases with reserved bytes at the end of each page. The format tes

Related repositories

Similar projects matched by category, topics, and programming language.

l0ng-ai
Featured
l0ng-ai GitHub avatar

tty7

tty7 is a fast, GPU-accelerated terminal workbench with persistent sessions, built-in input tools, SSH support, and coding agent awareness.

Developer ToolsCLI & Terminal
359
steelbrain
Featured
steelbrain GitHub avatar

reims-vgpu

reims-vgpu is an experimental virtual GPU for macOS guests that uses QEMU to decode the guest's GPU command stream and execute it through Metal or Vulkan, leveraging the built-in AppleParavirtGPU driver without requiring custom kexts.

Desktop Apps
143
m-novotny
Featured
m-novotny GitHub avatar

memguard-rs

A Rust library that provides secure memory handling primitives including zeroization on drop, memory locking, constant-time comparison, and compile-time guarded regions, with zero dependencies and no_std support.

Embedded & IoTSecurity
131