Python Django:异常值(2013,';2013:在查询期间与MySQL服务器的连接中断';,无)
最近,我将Django从1.6.5版升级到1.7.1版,将mysql连接器python从1.x升级到2.0.2版 升级后,我大多数查询时都会引发异常(2013)Python Django:异常值(2013,';2013:在查询期间与MySQL服务器的连接中断';,无),python,mysql,django,database-connection,django-1.7,Python,Mysql,Django,Database Connection,Django 1.7,最近,我将Django从1.6.5版升级到1.7.1版,将mysql连接器python从1.x升级到2.0.2版 升级后,我大多数查询时都会引发异常(2013) Exception Type: InterfaceError Exception Value: (2013, '2013: Lost connection to MySQL server during query', None) 我添加了一些关于“连接最大年龄”、“等待超时”的设置,但没有帮助。以下是我的设置: 从命令行: 从sett
Exception Type: InterfaceError
Exception Value: (2013, '2013: Lost connection to MySQL server during query', None)
我添加了一些关于“连接最大年龄”、“等待超时”的设置,但没有帮助。以下是我的设置:
从命令行:
从settings.py:
MySQL设置:
views.py:
请帮我解决这个问题。好的。我在附近挖了一些,看起来这是一个 该缺陷在2.0.3版中标记为“已解决”,但尚未发布 编辑:OP已将降级至1.2.3版报告为临时解决方案:
pip install -U --allow-external mysql-connector-python mysql-connector-python==1.2.3
我以前从未见过那个数据库引擎。在我新安装的Django 1.7中,它显示了'ENGINE':'Django.db.backends.mysql'数据库引擎的配置如下,mysql连接器python确实导致了这个问题。版本2.0.3尚未发布,因此我将mysql连接python降级为版本1.2.3。它解决了这个问题。多谢各位
pip安装-U——允许外部mysql连接器python mysql连接器python==1.2.3
DATABASES = {
'default': {
'ENGINE': 'mysql.connector.django',
'NAME': 'djangodb',
'USER': 'djangodb',
'PASSWORD': '******',
'HOST': '********',
'PORT': '3306',
'CONN_MAX_AGE' : 600,
}
}
show variables like 'wait_timeout'; #=>28800
show variables like 'net_read_timeout'; #=>30
@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")
pip install -U --allow-external mysql-connector-python mysql-connector-python==1.2.3