Recently I have upgraded Django from version 1.6.5 to 1.7.1 and mysql-connector-python from 1.x to 2.0.2 After upgrading, the Exception(2013) is raised most of the time I make a query.
Exception Type: InterfaceError
Exception Value: (2013, '2013: Lost connection to MySQL server during query', None)
I have added some settings about 'CONN_MAX_AGE', 'wait_timeout' but it does not help. Here are my settings:
From command line:
C:/>pip freeze
Django==1.7.1
South==1.0.1
mysql-connector-python==2.0.2
.....
C:/python -c "import django; print(django.get_version())"
1.7.1
From settings.py:
DATABASES = {
'default': {
'ENGINE': 'mysql.connector.django',
'NAME': 'djangodb',
'USER': 'djangodb',
'PASSWORD': '******',
'HOST': '********',
'PORT': '3306',
'CONN_MAX_AGE' : 600,
}
}
MySQL settings:
show variables like 'wait_timeout'; #=>28800
show variables like 'net_read_timeout'; #=>30
views.py:
@user_passes_test(lambda u: u.is_superuser)
def db(request, table):
from django.db import connection
cursor = connection.cursor()
if table == "table_status":
cursor.execute("SHOW TABLE STATUS") #No exception 4/5 times
elif table == "processlist":
cursor.execute("SHOW PROCESSLIST") #No exception 4/5 times
elif table == "status":
cursor.execute("SHOW STATUS") #No exception 4/5 times
elif table == "variables":
cursor.execute("SHOW VARIABLES") #Exception is raised 49/50 times
if(cursor):
data = cursor.fetchall()
description = cursor.description
cursor.close()
return render_to_response("myadmin/table.html", {"title": table, "headers":description,"data":data})
else:
return render_to_response("ajax/error404.html")
Please help me fix the problem.