This is a starting point for C++ solutions to the "Build Your Own SQLite" Challenge.
In this challenge, you'll build a barebones SQLite implementation that supports
basic SQL queries like SELECT. Along the way we'll learn about
SQLite's file format, how indexed data
is
stored in B-trees
and more.
Note: If you're viewing this repo on GitHub, head over to codecrafters.io to try the challenge.
The entry point for your SQLite implementation is in src/main.cpp. Study and
uncomment the relevant code, and then run the command below to execute the tests
on our servers:
codecrafters submitTime to move on to the next stage!
Note: This section is for stages 2 and beyond.
- Ensure you have
cmakeinstalled locally - Run
./your_program.shto run your program, which is implemented insrc/main.cpp. - Run
codecrafters submitto submit your solution to CodeCrafters. Test output will be streamed to your terminal.
To make it easy to test queries locally, we've added a sample database in the
root of this repository: sample.db.
This contains two tables: apples & oranges. You can use this to test your
implementation for the first 6 stages.
You can explore this database by running queries against it like this:
$ sqlite3 sample.db "select id, name from apples"
1|Granny Smith
2|Fuji
3|Honeycrisp
4|Golden DeliciousThere are two other databases that you can use:
superheroes.db:- This is a small version of the test database used in the table-scan stage.
- It contains one table:
superheroes. - It is ~1MB in size.
companies.db:- This is a small version of the test database used in the index-scan stage.
- It contains one table:
companies, and one index:idx_companies_country - It is ~7MB in size.
These aren't included in the repository because they're large in size. You can download them by running this script:
./download_sample_databases.shIf the script doesn't work for some reason, you can download the databases directly from codecrafters-io/sample-sqlite-databases.