Is there a way to test an SQLAlchemy Connection?

You can have SQLAlchemy check for the liveness of the connection with the parameter pool_pre_ping: https://docs.sqlalchemy.org/en/13/core/engines.html#sqlalchemy.create_engine.params.pool_pre_ping

if True will enable the connection pool “pre-ping” feature that tests connections for liveness upon each checkout.

Simply enable it by using when you create your engine.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)