How to set connection timeout in SQLAlchemy

后端 未结 7 802
暗喜
暗喜 2020-12-14 16:00

I\'m trying to figure out how to set the connection timeout in create_engine(), so far I\'ve tried:

create_engine(url, timeout=10)
7条回答
  •  Happy的楠姐
    2020-12-14 16:17

    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

    ps: (the timeout is defined in seconds)

提交回复
热议问题