How to set connection timeout in SQLAlchemy

The right way is this one (connect_timeout instead of connection_timeout):

create_engine(db_url, connect_args={'connect_timeout': 10})

…and it works with both Postgres and MySQL

docs sqlalchemy connect-args

ps: (the timeout is defined in seconds)

Leave a Comment