Mysql
 sql >> Base de Dados >  >> RDS >> Mysql

Django - OperationalError:(2006, 'O servidor MySQL sumiu')


A ideia da solução é clara:reconecte-se ao mysql se a conexão atual estiver quebrada.

Por favor, verifique isso:
def make_sure_mysql_usable():
    from django.db import connection, connections
    # mysql is lazily connected to in django.
    # connection.connection is None means
    # you have not connected to mysql before
    if connection.connection and not connection.is_usable():
        # destroy the default mysql connection
        # after this line, when you use ORM methods
        # django will reconnect to the default mysql
        del connections._connections.default