Writing an SQLite clone from scratch in C. This project was heavily inspired from cstack's amazing guide on writing an SQL Database in C, and aims to build on top of it by extending its functionality to make it as close to SQLite as possble.
This project is unfinished and in active development. Pull requests, suggestions and any sort of help in general is always welcome :)
sqlite architecture (https://www.sqlite.org/arch.html)
A query goes through a chain of components in order to retrieve or modify data. The front-end consists of the:
- tokenizer
- parser
- code generator
The input to the front-end is a SQL query. the output is sqlite virtual machine bytecode (essentially a compiled program that can operate on the database).
The back-end consists of the:
- virtual machine
- B-tree
- pager
- os interface
- macOS: Install CMake using Homebrew
- Linux (Ubuntu): Follow this guide. Make sure to download the latest version of CMake.
Run make
, this will build the binary, then run ./tinysql mydb.db
to start.
- Run all tests at once by running
python -m unittest discover
- To run a specific test (e.g.):
python -m unittest test.test_insert
- To run a specific test case (e.g.):
python -m unittest test.test_insert.TestInsert.test_persistence