Shell + SQLite report practice kit — Yenra
Article: https://yenra.com/unix-shell-database-programming/
All orders and prices are fictional teaching data; unit_cents is integer cents.
Requirements: POSIX-style shell, mktemp, mv, rm and SQLite CLI supporting
.import --csv --skip 1 (tested with SQLite 3.53.4). Run in a trusted private folder.
Unzip, cd into sample, and run: sh report.sh
Expected: Wrote report.csv
Read report.csv: customer,total_cents / Ada,3200 / Ben,3000 (three lines).
Totals: Ada 2*1200+1*800=3200 cents; Ben 3*1000=3000 cents.
Run again: exactly the same totals; each run starts with an empty memory DB.
Failure exercise: save a copy of orders.csv, change one quantity to unknown,
run again and immediately inspect echo $? (expected 1).
The prior successful report.csv must remain byte-identical. Restore your fixture.
Each successful run replaces report.csv. No existing database is opened.
Constraints reject duplicate IDs, empty names, non-integer quantities and
amounts outside this example's bounds. They are not a full production CSV validator.
Use one scheduled runner per output. This small example has no shared-run locking.
Sources: https://www.sqlite.org/cli.html and https://www.sqlite.org/lang_createtable.html
