Level 6 / Project 14 - SQL Runbook Generator¶
Home: README
Learn Your Way¶
| Read | Build | Watch | Test | Review | Visualize | Try |
|---|---|---|---|---|---|---|
| — | This project | — | — | Flashcards | — | — |
Focus¶
- operational runbook artifact creation
Why this project exists¶
This project gives you level-appropriate practice in a realistic operations context. Goal: run the baseline, alter behavior, break one assumption, recover safely, and explain the fix.
Run (copy/paste)¶
Use <repo-root> as the folder containing this repository's README.md.
cd <repo-root>/projects/level-6/14-sql-runbook-generator
python project.py --input data/sample_input.txt --output data/output_summary.json
pytest -q
Expected terminal output¶
{
"runbooks_generated": 2,
"runbooks": [{"name": "table_maintenance", "steps": 3, ...}, ...],
"history": [...]
}
Expected artifacts¶
data/output_summary.json— generated runbook details with history- Passing tests (
pytest -q→ 6+ passed) - Updated
notes.md
Alter it (required)¶
- Add a custom template:
"backup_restore"with steps for backing up and restoring a table. - Add a
--executeflag that actually runs each SQL step against the database (with confirmation prompts in a real CLI). - Add step numbering and estimated execution time to the formatted output.
- Re-run script and tests after each change.
Break it (required)¶
- Request a non-existent template name and observe the error.
- Use a template parameter that contains SQL injection (
'; DROP TABLE users; --) and observe what happens. - Leave a required template parameter unset and observe the KeyError.
Fix it (required)¶
- Validate template names against available templates before generation.
- Add SQL injection detection in
validate_sqlfor common patterns. - Catch missing parameter errors and report which parameters are required.
Explain it (teach-back)¶
- Why is template-based SQL generation safer than string concatenation?
- What is the difference between
string.Templatesubstitution and parameterized queries? - Why store runbook history in a database instead of just generating text files?
- What is an operational runbook and why do teams maintain them?
Mastery check¶
You can move on when you can: - run baseline without docs, - explain one core function line-by-line, - break and recover in one session, - keep tests passing after your change.
Related Concepts¶
| ← Prev | Home | Next → |
|---|---|---|