Add db_session_middleware to main.py that opens the connection at the start of each request and closes it in a try/finally block, ensuring connections are always returned even on uncaught exceptions. Remove all individual db.close() calls from 30 router files in app/routers_v2/ — the middleware now handles all code paths. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> |
||
|---|---|---|
| .. | ||
| routers_v2 | ||
| __init__.py | ||
| card_creation.py | ||
| db_engine.py | ||
| db_helpers.py | ||
| dependencies.py | ||
| main.py | ||
| player_scouting.py | ||