- mysql
- The _extract_error_code() method now works
- correctly with the "mysqldb" dialect. Previously,
+ correctly with each MySQL dialect (
+ MySQL-python, OurSQL, MySQL-Connector-Python,
+ PyODBC). Previously,
the reconnect logic would fail for OperationalError
- conditions, however since MySQLdb has its
- own reconnect feature, there was no symptom
- here unless one watched the logs.
- [ticket:1848]
+ conditions, however since MySQLdb and OurSQL
+ have their own reconnect feature, there was no
+ symptom for these drivers here unless one
+ watched the logs. [ticket:1848]
0.6.2
=====
def is_disconnect(self, e):
if isinstance(e, self.dbapi.OperationalError):
- return self._extract_error_code(e) in (2006, 2013, 2014, 2045, 2055)
- elif isinstance(e, self.dbapi.InterfaceError): # if underlying connection is closed, this is the error you get
+ return self._extract_error_code(e) in \
+ (2006, 2013, 2014, 2045, 2055)
+ elif isinstance(e, self.dbapi.InterfaceError):
+ # if underlying connection is closed,
+ # this is the error you get
return "(0, '')" in str(e)
else:
return False
rs.close()
return have
except exc.SQLError, e:
- if self._extract_error_code(e) == 1146:
+ if self._extract_error_code(e.orig) == 1146:
return False
raise
finally:
try:
rp = connection.execute(st)
except exc.SQLError, e:
- if self._extract_error_code(e) == 1146:
+ if self._extract_error_code(e.orig) == 1146:
raise exc.NoSuchTableError(full_name)
else:
raise
try:
rp = connection.execute(st)
except exc.SQLError, e:
- if self._extract_error_code(e) == 1146:
+ if self._extract_error_code(e.orig) == 1146:
raise exc.NoSuchTableError(full_name)
else:
raise
return connection.connection.get_characterset_info()
def _extract_error_code(self, exception):
- try:
- return exception.orig.errno
- except AttributeError:
- return None
+ return exception.errno
def is_disconnect(self, e):
errnos = (2006, 2013, 2014, 2045, 2055, 2048)
return tuple(version)
def _extract_error_code(self, exception):
- try:
- return exception.args[0]
- except AttributeError:
- # this AttributeError is likely unnecessary,
- # but would need to confirm against MySQLdb code
- return None
+ return exception.args[0]
def _detect_charset(self, connection):
"""Sniff out the character set in use for connection results."""
return tuple(version)
def _extract_error_code(self, exception):
- try:
- return exception.orig.errno
- except AttributeError:
- return None
+ return exception.errno
def _detect_charset(self, connection):
"""Sniff out the character set in use for connection results."""
return 'latin1'
def _extract_error_code(self, exception):
- m = re.compile(r"\((\d+)\)").search(str(exception.orig.args))
+ m = re.compile(r"\((\d+)\)").search(str(exception.args))
c = m.group(1)
if c:
return int(c)