{"id":19963231,"url":"https://github.com/bilbottom/sql-learning-materials","last_synced_at":"2025-05-03T22:31:58.232Z","repository":{"id":223369913,"uuid":"760131472","full_name":"Bilbottom/sql-learning-materials","owner":"Bilbottom","description":"SQL scripts that demonstrate various features and concepts.","archived":false,"fork":false,"pushed_at":"2024-11-10T11:40:17.000Z","size":1334,"stargazers_count":7,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-11-10T12:28:40.328Z","etag":null,"topics":["duckdb","postgresql","sql","sql-server","sqlite"],"latest_commit_sha":null,"homepage":"https://bilbottom.github.io/sql-learning-materials/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Bilbottom.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-02-19T20:55:08.000Z","updated_at":"2024-11-10T11:40:20.000Z","dependencies_parsed_at":"2024-02-19T22:31:05.563Z","dependency_job_id":"86b957d3-57b2-49fe-b5b3-e46e4330399d","html_url":"https://github.com/Bilbottom/sql-learning-materials","commit_stats":null,"previous_names":["bilbottom/sql-learning-materials"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bilbottom%2Fsql-learning-materials","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bilbottom%2Fsql-learning-materials/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bilbottom%2Fsql-learning-materials/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bilbottom%2Fsql-learning-materials/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Bilbottom","download_url":"https://codeload.github.com/Bilbottom/sql-learning-materials/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224374655,"owners_count":17300691,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["duckdb","postgresql","sql","sql-server","sqlite"],"created_at":"2024-11-13T02:15:11.231Z","updated_at":"2025-05-03T22:31:58.221Z","avatar_url":"https://github.com/Bilbottom.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n\n[![Python](https://img.shields.io/badge/Python-3.11+-blue.svg)](https://www.python.org/downloads/)\n[![uv](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/uv/main/assets/badge/v0.json)](https://github.com/astral-sh/uv)\n[![Docker](https://img.shields.io/badge/Docker-24.0.5-blue.svg)](https://www.docker.com/)\n[![GitHub last commit](https://img.shields.io/github/last-commit/Bilbottom/sql-learning-materials)](https://shields.io/badges/git-hub-last-commit-by-committer)\n\n[![SQL Server](https://img.shields.io/badge/SQL%20Server-2022-teal.svg)](https://www.microsoft.com/en-gb/sql-server/sql-server-downloads)\n[![MySQL](https://img.shields.io/badge/MySQL-8.4-teal.svg)](https://dev.mysql.com/downloads/mysql/)\n[![PostgreSQL](https://img.shields.io/badge/PostgreSQL-16.2-teal.svg)](https://www.postgresql.org/download/)\n[![ClickHouse](https://img.shields.io/badge/ClickHouse-24.8-teal.svg)](https://clickhouse.com/docs/en/install)\n[![SQLite](https://img.shields.io/badge/SQLite-3.45-teal.svg)](https://www.sqlite.org/index.html)\n[![DuckDB](https://img.shields.io/badge/DuckDB-1.1-teal.svg)](https://duckdb.org/)\n\n\u003c/div\u003e\n\n---\n\n# SQL Learning Materials\n\nSQL scripts that demonstrate various features and concepts.\n\nThis project contains a bunch of SQL learning materials aimed at different levels of experience and covering a variety of topics. It focuses on just writing `SELECT` statements so there will be very few resources for anything else.\n\nJump into [https://bilbottom.github.io/sql-learning-materials/](https://bilbottom.github.io/sql-learning-materials/) to see the summary of what's covered in this project, and continue below for instructions on how to set up the databases.\n\n## Acknowledgements\n\nThe data used in this project is from a couple of sources.\n\nThe SQL Server instance will load the ubiquitous _AdventureWorks_ databases (the transactional one and the analytical one), which is available from various Microsoft pages:\n\n- https://learn.microsoft.com/en-us/sql/samples/adventureworks-install-configure\n- https://github.com/Microsoft/sql-server-samples/releases/download/adventureworks\n\nThe PostgreSQL instance will load the similarly ubiquitous _Sakila_ database, which is available from the following GitHub repo:\n\n- https://github.com/jOOQ/sakila/\n\nAll credit for the data goes to the respective owners, and these sources should be consulted for any documentation you need around the data.\n\nThe docs are built using [MkDocs](https://www.mkdocs.org/) and the [Material for MkDocs](https://squidfunk.github.io/mkdocs-material/) theme, with several plugins to make the experience more interactive. I cannot express the love I have for the maintainers of these tools!\n\n## Pre-requisites\n\nThis project uses [uv](https://docs.astral.sh/uv/) to manage the Python dependencies and [Docker](https://www.docker.com/) to spin up the databases.\n\nTo install these, follow the instructions on their websites:\n\n- https://docs.astral.sh/uv/getting-started/installation/\n- https://www.python.org/downloads/\n- https://docs.docker.com/get-docker/\n\n## Quick start\n\nAfter installing the pre-requisites and cloning this repo, just run the `resources` package to download the files needed to feed into the SQL Server and PostgreSQL databases before running Docker's `compose` command.\n\n```bash\nuv sync --all-groups\npython -m src.resources\ndocker compose --profile build up --detach\nmkdocs build\nmkdocs serve\ndocker compose down --volumes  # When you're finished\n```\n\nThis will take a little while to run since there's a fair bit of data to chunk through.\n\nYou can connect to the databases using any of your favourite SQL clients.\n\nThe credentials for the databases are not sensitive and are defined in the `docker-compose.yml` file. For reference, the credentials are:\n\n| Database   | Username | Password   | Host      | Port |\n| ---------- | -------- | ---------- | --------- | ---- |\n| SQL Server | SA       | Test@12345 | localhost | 1433 |\n| MySQL      | root     | Test@12345 | localhost | 3306 |\n| PostgreSQL | postgres | Test@12345 | localhost | 5432 |\n| ClickHouse |          |            | localhost | 8123 |\n\nNote that ClickHouse can be connected to without any authentication.\n\nThe SQLite and DuckDB databases are just files, so using Docker for these is overkill -- when you run `python -m resources`, the files for these databases will be created in your file system. The file locations are defined in the `resources.toml` config file (you can override them there if you want) and are:\n\n| Database | File location                         |\n| -------- | ------------------------------------- |\n| SQLite   | `src/resources/data/sqlite/loan.db`   |\n| DuckDB   | `src/resources/data/duckdb/duckdb.db` |\n\nThe Metabase instance will be launched on [`localhost:3000`](http://localhost:3000) and you will have to configure your own login details.\n\n## On an M1 mac...\n\n...you will have to make sure that you have enabled the virtualisation framework and Rosetta for amd64 support, see the following GitHub issue and comment:\n\n- https://github.com/microsoft/mssql-docker/issues/668#issuecomment-1436802153\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbilbottom%2Fsql-learning-materials","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbilbottom%2Fsql-learning-materials","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbilbottom%2Fsql-learning-materials/lists"}