A learning environment for practicing SQLite queries with example and fictional data. This project provides a structured way to learn SQL concepts through practical exercises using a pre-populated SQLite database.
This project helps learners practice SQL with:
- A pre-configured SQLite database with fictional data
- Structured lessons and exercises
- Easy database resets for experimentation
- Real-world-like scenarios + practical examples
- Python 3.7 or higher (Anaconda's Distribution Recommended)
- SQLite 3.x (Included With Python)
- Git + Beginner or Basic Git Knowledge
- Beginner or Basic Python knowledge
- Basic command line knowledge
- Clone this repository:
git clone https://github.com/adamrossnelson/sql-sandbox.git- In the project folder (
cd sql-sandbox), set up the learning environment:
python build-sandbox.pyThis will create and populate your SQLite database with fictional data.
If you want to start fresh or reset your database to its original state:
python reset-sandbox.pyAfter setting up your environment, you can start exploring the data:
- Open SQLite command line interface:
sqlite3 sandbox.dbNote: If you encounter an error at this sqlite3 sandbox.db step consider the following checks and solutions:
- Ensure you've installed the necessary tools and environments. We recommend Anaconda's distrution of Python which should include all necessary tools.
- A second option, especially if you've already instealled Anaconda is to install or update to the most recent versions of SQLite available here.
- Look to install the the "Precompiled Binaries" for your computer and OS. The filename will resemble:
sqlite-tools-win-x64-3500100.zip. - Also, if on a Windows PC, consider adding
C:\sqlite\sqlitetools(or the equivalent for your setup to your System Path. A computer restart may also be necessary.
- Once in SQLite, you can see available tables:
.tables- View the structure of the mpg table:
.schema mpg- Find the five most fuel efficient vehicles:
SELECT name, model_year, weight, mpg
FROM mpg
ORDER BY mpg DESC
LIMIT 5;- Return to system cli / terminal:
.quitThe sandbox database includes the following tables from Seaborn's example datasets:
A dataset of car fuel efficiency from 1999 to 2008, including:
- manufacturer, model, year
- engine displacement, cylinders
- city and highway MPG ratings
- vehicle class
Restaurant tipping behavior data including:
- bill total and tip amount
- day of week, time of day
- party size
- server gender
Measurements of Antarctic penguins including:
- species (Adelie, Gentoo, Chinstrap)
- bill length and depth
- flipper length
- body mass
- island location
Contributions are welcome! Please feel free to submit a Pull Request.
- Create a way to specify the database name
- Add a small set of realistic relational tables with fictional data (e.g., bookstore, library, or school system)
- Add command line arguments support for both scripts (e.g., --quiet, --force)
- Add option to backup existing database before modifications
- Add example queries for common SQL operations
- Create a series of progressive SQL exercises
- Create troubleshooting guide for common SQL errors
- Add unit/integration tests
This project is licensed under the MIT License - see the LICENSE file for details.

