django.db.utils.InterfaceError: (0, '')
Because the default
wait_timeout=28800 of the database, the unit is second (s), it is 8 hours when converted to hours (it is related to the mysql setting information). That is, once my service is started, it will be automatically disconnected by mysql after 8 hours.
This is caused by the global cursor. Try to create and close the cursor within each method, which requires the original query.
cursor = connection.cursor() cursor.execute(query) cursor.close()
with connections.cursor() as cursor: cursor.execute(sql)