testsAndMisc/python_pkg/sql_drills/README.md
Krzysztof kuhy Rudnicki ee78ae44cc
Some checks are pending
dependency freshness / dependencies on newest stable (push) Waiting to run
md-naming / markdown naming convention (push) Waiting to run
Pre-commit checks / pre-commit (${{ matrix.group }}) (mypy, mypy) (push) Waiting to run
Pre-commit checks / pre-commit (${{ matrix.group }}) (pylint, pylint) (push) Waiting to run
Pre-commit checks / pre-commit (${{ matrix.group }}) (rest, ) (push) Waiting to run
Pre-commit checks / pre-commit (${{ matrix.group }}) (shellcheck, shellcheck) (push) Waiting to run
Python tests / test (push) Waiting to run
repo-contract / repo contract (push) Waiting to run
Shell tests / shell-tests (push) Waiting to run
Shell tests / lib-tests (push) Waiting to run
Shell tests / arch-tests (push) Waiting to run
Add sql_drills MySQL exact-match harness
Docker mysql:8.0.33 container, judge-style output grading, 12 original drills with live-verified references kept in tests only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WzxdWZewj4WS5X6AZyjWDp
2026-11-01 21:13:18 +01:00

33 lines
1.4 KiB
Markdown

# sql_drills
MySQL 8 practice drills graded like an online judge: the query's output must
match the expected text exactly. Engine: Docker image `mysql:8.0.33`
(pinned on purpose; do not bump). Needs Docker and your user in the `docker`
group.
```bash
python3 -m python_pkg.sql_drills start # container + wait (<60 s)
python3 -m python_pkg.sql_drills list # ids and titles
python3 -m python_pkg.sql_drills show 01 # task, schema, output sample
python3 -m python_pkg.sql_drills check 01 my.sql # grade my.sql (exit 0 = pass)
python3 -m python_pkg.sql_drills stop # remove the container
```
Drills are addressed by full id (`01_pivot_sum`) or leading number (`01`).
## Grading rules
Output is `mysql -B -N` style: no header, tab separators become single
spaces, `NULL` prints as `NULL`, trailing whitespace is stripped per line.
Nothing else is normalised: case, decimal places and row order are strict, so
add the `ORDER BY` the task asks for. On mismatch you get an expected vs
actual diff per line. A fresh database is built for every check.
## Layout
- `fixtures/<id>/` holds `DOCS-task.md`, `schema.sql`, `expected.txt`.
- Reference solutions live only in `tests/solutions/`; `show` and `check`
never print them.
- `tests/test_live.py` runs every reference against the container (marker
`docker`, skipped when the container is down).