feat: implement async SQLAlchemy database engine and session management with Neon-compatible configurations
Browse files- backend/src/database.py +3 -0
backend/src/database.py
CHANGED
|
@@ -39,6 +39,9 @@ engine = create_async_engine(
|
|
| 39 |
_db_url,
|
| 40 |
echo=False,
|
| 41 |
pool_pre_ping=True,
|
|
|
|
|
|
|
|
|
|
| 42 |
connect_args=_connect_args,
|
| 43 |
# This disables SQLAlchemy's internal prepared statement cache globally
|
| 44 |
execution_options={"prepared_statement_cache_size": 0}
|
|
|
|
| 39 |
_db_url,
|
| 40 |
echo=False,
|
| 41 |
pool_pre_ping=True,
|
| 42 |
+
pool_recycle=300, # Drop idle connections aggressively (every 5 mins) to prevent Neon Serverless drops
|
| 43 |
+
pool_size=10, # Constrain pool size for Free Tier
|
| 44 |
+
max_overflow=5,
|
| 45 |
connect_args=_connect_args,
|
| 46 |
# This disables SQLAlchemy's internal prepared statement cache globally
|
| 47 |
execution_options={"prepared_statement_cache_size": 0}
|