rgSQL is a SQL database server that YOU get to build from scratch.
More about rgSQL and why it was created.
This project contains a test runner and 200+ test cases to guide you through creating a database server. The tests check your implementation can parse, type check and evaluate SQL statements.
The test suite starts with simpler statements such as SELECT 1;
and builds up to more complex queries that can evaluate expressions, join tables and run aggregate functions on grouped data.
To start, fork this repository. Then clone it and run:
./run-tests
Next, follow the instructions of the test runner. You can choose what programming language you want to build your implementation in.
If you want more guidance and suggestions for building your implementation, see the Build a Database Server book.
The tests/
directory contains 13 files that check different parts of your implementation. Here's an example test that checks that you can insert multiple rows at once:
--- can insert multiple rows
CREATE TABLE t1(a INTEGER, b INTEGER);
INSERT INTO t1 VALUES (1, 2), (3, 4);
SELECT a, b FROM t1;
--- returns:
1, 2
3, 4
Get the Build a Database Server book to get:
- A 13 chapter guide on how to build your rgSQL implementation.
- In depth explanations of how to write a parser, build a type checker, and create a query plan with iterators.
- Details about important SQL and relational database concepts such as atomicity and 3-valued logic.
- Comparisons between rgSQL and databases such as PostgreSQL, MySQL, SQLite and DuckDB.
- 30+ extension projects that add to your implementation.
- Ideas on how to structure and refactor your code, including a sample solution.
- Access to a Discord server to share solutions and ask for help.
- Instructions on how to work with and extend the rgSQL test suite.