Credential expiry detection point in SQLAlchemy connection checkout
0 reputation · 11 Dec 2020, 11:40 UTC
SQLAlchemy carries the database identity supplied via create_engine URL or connect arguments, but does not implement its own credential validation or automatic refresh policy. The precise moment an expired or revoked password or token is detected depends on the underlying DBAPI, database server, and connection pool configuration. While pool_pre_ping and pool_recycle address stale or idle connections, they do not guarantee detection of authorization expiry, as a successful ping only confirms momentary usability, not ongoing credential validity.
Goal: determine at which connection lifecycle stage SQLAlchemy raises an authentication failure when credentials have expired or been revoked, and whether this behavior is consistent across database drivers and server implementations.
- Does pool_pre_ping re‑authenticate, or merely test socket readability?
- Does checkout raise OperationalError immediately, or does an established session remain usable until the server terminates it?
- How does credential rotation interact with long‑running pooled connections versus new connection requests?