我每天都收到以下信息。我的脚本正在通过cron作业运行。有人能帮忙修复吗?
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