python 连接mysql 时,connect 出现错误,怎么解决
展开全部
python 连接mysql 时,connect 出现错误,解决
# -*- coding: utf-8 -*-
import MySQLdb
from MySQLdb.cursors import DictCursor
def catch_2006(func):
"""
To catch MySQL Error 2006 ('Server has gone away')
"""
def _(self, *args, **kwargs):
try:
return func(self, *args, **kwargs)
except MySQLdb.Error, e:
print __file__, e
if e.args[0] == 2006 or e.args[0] == 0:
# -*- coding: utf-8 -*-
import MySQLdb
from MySQLdb.cursors import DictCursor
def catch_2006(func):
"""
To catch MySQL Error 2006 ('Server has gone away')
"""
def _(self, *args, **kwargs):
try:
return func(self, *args, **kwargs)
except MySQLdb.Error, e:
print __file__, e
if e.args[0] == 2006 or e.args[0] == 0:
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询