A tiny educational SQL engine written in pure Python.
Project description
FoundryDB
A tiny educational SQL engine written in pure Python.
FoundryDB is a personal experimental project to explore how relational database systems actually work under the hood. From parsing SQL, to planning, to storage and tuple access.
This is not production-grade software. It's a playground.
Goals
- Teach myself the internal moving parts of a DBMS
- Be small enough to understand in a single sitting
- Pure Python
- Transparent / readable code > performance
Non-goals
- Competing with SQLite or Postgres
- Correctness for all SQL edge cases
- Maximizing speed
Rough architecture (planned)
| Layer | Responsibility |
|---|---|
| Lexer/Parser | tokenize & parse SQL into AST |
| Planner | validate AST + generate logical plans |
| Execution Engine | run plans against storage |
| Storage | page format, files, catalog, indexes (maybe later) |
Phases
Phase 1: Core Storage Engine (v0.1)- Phase 2: Simple Query Language (v0.1)
- Phase 3: Data Types & Schema Management (v0.2)
- Phase 4: Basic Indexing (v0.2)
- Phase 5: INSERT, UPDATE, DELETE (v0.2)
- Phase 6: Page‑Based Storage (v0.3)
- Phase 7: Multi‑Table Queries (JOINs) (v0.4)
- Phase 8: Aggregations & Grouping (v0.4)
- Phase 9: Basic Transactions (v0.5)
- Phase 10: Query Optimization (v0.6)
- Phase 11: Advanced Indexes (v0.7)
- Phase 12: Concurrency Control (v0.7)
- Phase 13: Constraints & Foreign Keys (v0.8)
- Phase 14: Views & Subqueries (v0.8)
- Phase 15: Advanced Features (v0.9+)
Roadmap ideas
SELECTwith projections + simpleWHERE+ other DDL and DML commands- Disk-backed heap file manager
- Simple B-Tree index (stretch goal)
- Minimal transaction log + recovery (stretch goal)
Requirements
- Python ≥ 3.11
Testing
Run
pip install -e .
pip install ruff
From the foundrydb folder to add the package to sys.path. This step is necessary before running tests.
At the project root, run:
pytest -v
You should see something like:
tests/test_database.py::test_database_initialization PASSED
tests/test_database.py::test_execute_returns_list PASSED
tests/test_storage.py::test_table_insert_and_persist PASSED
Run ruff to do some linting checks
ruff check .
ruff format .
License
This project is licensed under the MIT License.
See LICENSE for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file foundrydb_core-0.1.0.tar.gz.
File metadata
- Download URL: foundrydb_core-0.1.0.tar.gz
- Upload date:
- Size: 6.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6e72b857745e926f86fcf43ef154370ff380e29a11f9037b200072c8adf56347
|
|
| MD5 |
a739f574a50417869159d95de84e76f8
|
|
| BLAKE2b-256 |
9841921da48eba1ce59221e787ddaac23977e452d2ea4218b3076b9edf7d18a8
|
File details
Details for the file foundrydb_core-0.1.0-py3-none-any.whl.
File metadata
- Download URL: foundrydb_core-0.1.0-py3-none-any.whl
- Upload date:
- Size: 7.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
31d4be9c9c42b0eddabcbc719ad2da34c6af713b6a3c82c6d22c24128de79b34
|
|
| MD5 |
a27f2a503441e5cfd12b6105ae3fc962
|
|
| BLAKE2b-256 |
e08bbaadc38fe017aac8419df35a21c95a0353b202b001ad39e3bcc38ea0328c
|