Spaces:
Running
Running
| from sqlmodel import create_engine | |
| import os | |
| from config import settings | |
| engine = create_engine(settings.database_url, | |
| echo=True, | |
| pool_size=10, # Keep 10 connections permanently open and ready | |
| max_overflow=20, # Allow up to 20 temporary extra connections during traffic spikes | |
| # How long to wait for an available connection before throwing an error | |
| pool_timeout=30, | |
| # Pings the DB slightly before executing a query to ensure the connection didn't drop | |
| pool_pre_ping=True, | |
| pool_recycle=1800 # Refresh connections every 30 minutes to prevent stale timeouts | |
| ) | |