from sqlalchemy import create_engine, event
from sqlalchemy.exc import DisconnectionError

def checkout_listener(dbapi_con, con_record, con_proxy):
    pass
Python SQLAlchemy - "MySQL server has gone away"