Skip to content

python.sqlalchemy.connection_pool

Stability High

Detects SQLAlchemy without proper connection pool configuration.

Poor pool configuration:

  • Connection exhaustion — Pool runs out
  • Stale connections — Dead connections in pool
  • Memory leaks — Connections not recycled
# ❌ Before (default pool settings)
engine = create_engine('postgresql://...')
# ✅ After (proper pool configuration)
from sqlalchemy import create_engine
engine = create_engine(
'postgresql://...',
pool_size=5,
max_overflow=10,
pool_timeout=30,
pool_recycle=1800, # Recycle connections every 30 min
pool_pre_ping=True, # Test connections before use
)
  • Missing pool_size configuration
  • No pool_recycle (stale connections)
  • Missing pool_pre_ping