6
我每天都會收到以下消息。我的腳本正在運行cron作業。誰能幫助解決這個問題嗎?MySQL服務器已經消失 - Python
File "/usr/lib64/python2.6/site-packages/MySQLdb/cursors.py", line 174, in execute
self.errorhandler(self, exc, value)
File "/usr/lib64/python2.6/site-packages/MySQLdb/connections.py", line 36, in defaulterrorhandler
raise errorclass, errorvalue
_mysql_exceptions.OperationalError: (2006, 'MySQL server has gone away')
我的代碼:
def get_id(test_mysql_conn,id):
cursor = test_mysql_conn.cursor()
cursor.execute("""select id from test where id = %s """, (id))
row = cursor.fetchone()
if row is not None:
return row[0]
return 0
看看這個答案:http://stackoverflow.com/a/982873/974317 – 2015-02-05 12:47:19
檢查[此] (http://dev.mysql.com/doc/refman/5.0/en/gone-away.html)。 – 2015-02-05 13:12:11
有關詳細信息,當您超出最大數據包大小時可能會發生此錯誤:請參閱[這裏](http://serverfault.com/a/528183/341327) – PlasmaBinturong 2016-06-08 14:41:35