“查询过程中丢失连接到MySQL服务器的”我使用如何捕捉特定的错误
def mysql_handling(string):
global cursor
while True:
try:
cursor.execute(string)
if 'SELECT' not in string:
db.commit()
break
except MySQLdb.MySQLError:
cursor.close()
print 'something went wrong!!'
time.sleep(1)
cursor = get_cursor()
如果要在连接失败重新进行查询,但我ONLY要重新连接时,我有错误“查询期间与MySQL服务器失去连接”。 (否则mysql_handling函数进入无限循环)
那么我应该用什么来代替'除了MySQLdb.MySQLError:'?
谢谢你的回答! – Lazykiddy 2013-03-05 13:35:20