https://github.com/pythoninthegrass/learn_sql
Follows LearnSQL course content with local dev scaffolding
https://github.com/pythoninthegrass/learn_sql
docker mysql postgres python sql
Last synced: 8 months ago
JSON representation
Follows LearnSQL course content with local dev scaffolding
- Host: GitHub
- URL: https://github.com/pythoninthegrass/learn_sql
- Owner: pythoninthegrass
- License: unlicense
- Created: 2023-10-03T20:43:48.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2025-02-07T23:03:40.000Z (about 1 year ago)
- Last Synced: 2025-03-01T01:25:58.390Z (about 1 year ago)
- Topics: docker, mysql, postgres, python, sql
- Language: Shell
- Homepage: https://learnsql.com
- Size: 140 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# learn_sql
Smattering of content from [LearnSQL.com](https://learnsql.com/) (née [Vertabelo Academy](https://academy.vertabelo.com/)).
## Setup
* Install
* [editorconfig](https://editorconfig.org/)
* [asdf](https://asdf-vm.com/guide/getting-started.html#_2-download-asdf)
* [poetry](https://python-poetry.org/docs/)
* [docker-compose](https://docs.docker.com/compose/install/)
## Quickstart
```bash
# install python
asdf install python 3.11.5
# install poetry
asdf install poetry 1.6.1
# spin up database container
λ ./bin/bootstrap
Which database do you want to use?
1) mysql
2) postgres
Enter your choice: 1
MySQL is already running. Skipping...
Starting container...
Creating database...
Setting up database...
Connecting to database...
mysql>
#!DANGER WILL ROBINSON!: replaces existing table and values
# import csv
λ poetry shell
λ ./bin/import_data.py ./course/insert-update-delete/intro/dish.csv dish
Data imported successfully
# connect to db
λ docker exec -it some-mysql bash
root@6c778a74e8a3:/# mysql -u root -p -h localhost
Enter password:
mysql> USE db;
mysql> SELECT * FROM dish;
+------+-------------+-----------------+-------+
| id | type | name | price |
+------+-------------+-----------------+-------+
| 1 | starter | Prawn Salad | 13 |
| 2 | starter | Spring Scrolls | 11 |
| 3 | main course | Asian Noodles | 25 |
| 4 | main course | Pork Roast | 32 |
| 5 | main course | Chicken Nuggets | 24 |
| 6 | main course | Pizza Italiana | 30 |
| 7 | dessert | Peach Cobbler | 10 |
| 8 | dessert | Cherry Brownies | 12 |
+------+-------------+-----------------+-------+
8 rows in set (0.01 sec)
mysql> exit;
Bye
```
## TODO
* Finish course(s)
* Python
* Add properties test (hypothesis)
* Test postgres
* Add docker shim
## Further Reading
[mysql - Official Image | Docker Hub](https://hub.docker.com/_/mysql/)
[postgres - Official Image | Docker Hub](https://hub.docker.com/_/postgres)
[Python Database Tutorials – Real Python](https://realpython.com/tutorials/databases/)
[TablePlus | Modern, Native Tool for Database Management](https://tableplus.com/)