Avoiding “MySQL server has gone away” on infrequently used Python / Flask server with SQLAlchemy
I’ve had trouble with this before, and found that the way to handle it is by not keeping sessions around. The trouble is you are trying to keep a connection open for way too long. Instead, use a thread local scoped session like so either in __init__.py or in a utility package that you import … Read more