python 连接mysql 时,connect 出现错误,怎么解决
2016-07-05
展开全部
# -*- 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
...
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
...
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询