Sql Alchemy connection time Out Sql Alchemy connection time Out python python

Sql Alchemy connection time Out


Whenever you create a new session in your code, make sure you close it. Just call session.close()

When I got this error I thought I was closing all of my sessions, but I looked carefully and there was one new method where I wasn't. Closing the session in that method fixed this error for me.


In multi-thread mode, if your concurrent request num is much more than the db connection pool size, it will throw the Queue Pool limit of size 5 overflow 10 reached error. try with this:

engine = create_engine('mysql://', convert_unicode=True, pool_size=20, max_overflow=100)to add the pool size

Add: the method above is not a correct way. The actual reason is that db connection pool is used up, and no other available connection. The most probably situation is you miss to release connection. For example:

@app.teardown_appcontextdef shutdown_session(exception=None):    db_session.remove()