Problem
Every request handler currently opens its own SQLite connection with a boilerplate `try/finally` block. This is repetitive and makes it easy to leak connections on new routes.
Proposal
- Store the connection on `flask.g` inside a helper `get_request_db()`.
- Register `@app.teardown_appcontext` to close it.
- Delete the per-handler `try/finally: db.close()` noise.
- Helpers `get_setting`/`set_setting` reuse the request connection when one exists.
Acceptance
- All existing endpoints keep their behaviour (green test suite).
- Handler code size reduced significantly.
Problem
Every request handler currently opens its own SQLite connection with a boilerplate `try/finally` block. This is repetitive and makes it easy to leak connections on new routes.
Proposal
Acceptance