A minimal SQLite implementation in Rust that parses the SQLite file format and executes basic SQL queries.
Built to learn Rust and understand database internals.
- File Format Parsing: Reads SQLite database headers, page structures, and B-tree data
- Query Support:
SELECT COUNT(*) FROM <table>SELECT <columns> FROM <table>SELECT <columns> FROM <table> WHERE <column> = '<value>'
- Index Optimization: Automatically uses B-tree indexes for
WHEREclause filtering when available - Data Types: Handles INTEGER, TEXT, REAL, and BLOB columns
Requires cargo (1.91) or later.
./your_program.sh sample.db "SELECT id, name FROM apples"The first run compiles the project and may be slow. Subsequent runs are fast.
Included:
sample.db- Small database withapplesandorangestables (~few KB)
Download separately:
./download_sample_databases.shsuperheroes.db- 1MB database for testing table scanscompanies.db- 7MB database with an index for testing index scans
Explore databases with:
sqlite3 sample.db "SELECT id, name FROM apples"Topics explored:
- SQLite's file format
- B-tree storage structures
- Query optimization with indexes
- Rust systems programming