Forums

Flask: MySQL Connection not available

Just moved from 3.9 to Python 3.10 and from SQL Alchemy 1.4 to SQL Alchemy 2.0. After about 5 minutes of inactivity, I now get a "MySQL Connection not available" at the first connection, but not at the following ones.

My config class already included:

SQLALCHEMY_POOL_RECYCLE = 299

I am trying to see if changing to:

SQLALCHEMY_POOL_RECYCLE = 280
SQLALCHEMY_POOL_TIMEOUT = 10
SQLALCHEMY_POOL_PRE_PING = True

has any effects, but it's not easy to debug. Do you have any pointers of possible issues?

I think I had misread the post help page at https://help.pythonanywhere.com/pages/UsingSQLAlchemywithMySQL/ , which already addressed the issue. Sorry, the post can be closed.

OK, glad to hear you worked it out!