Spaces:
Running
Running
File size: 782 Bytes
f2cb2b4 929258f | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | 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
)
|