Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

sakdb

A SQLite-compatible embedded database engine written from scratch in Rust.

Status: Early development. Not ready for production use.

Goals

  • Full SQL support (CREATE TABLE, INSERT, SELECT, UPDATE, DELETE, JOINs, subqueries, aggregations)
  • ACID transactions via WAL (Write-Ahead Logging)
  • B-tree indexed storage
  • Small footprint, single-file database
  • Drop-in compatibility with the SQLite C API (via FFI in future)
  • No external dependencies beyond the Rust standard library

Architecture

src/
├── sql/        Lexer → Parser → AST
├── planner/    Query optimization & plan generation
├── vdbe/       Virtual Database Engine (bytecode VM)
├── btree/      B-tree index & table storage
├── pager/      Page cache & WAL transaction manager
├── storage/    File I/O, disk layout, schema management
└── cli/        Interactive REPL shell

Pipeline

SQL text → Lexer → Tokens → Parser → AST → Planner → Bytecode → VDBE → B-tree → Pager → Disk

Building

cargo build --release

Usage

# Start REPL (data sparas i sakdb.db som standard)
cargo run

# Eller ange en sökväg
cargo run -- min.db

This starts an interactive SQL shell. All data persists to disk as JSON:

sakdb> CREATE TABLE users (id INT PRIMARY KEY, name TEXT);
sakdb> INSERT INTO users VALUES (1, 'Alice');
sakdb> SELECT * FROM users;
1|Alice
sakdb> .exit

Milestones

  • Phase 1 – Lexer, Parser, AST for DDL + simple DML
  • Phase 2 – B-tree storage engine, pager, WAL
  • Phase 3 – VDBE execution engine, INSERT/SELECT with WHERE
  • Phase 4 – Indexes, constraints, transactions
  • Phase 5 – JOINs, subqueries, GROUP BY, aggregations
  • Phase 6 – C API compatibility layer, SQLite file format support

License

MIT

About

No description, website, or topics provided.

Resources

Contributing

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages