Skip to content

Instantly share code, notes, and snippets.

@noelbk
Created October 27, 2014 17:34
Show Gist options
  • Save noelbk/9f83e5ccf82d60bac19e to your computer and use it in GitHub Desktop.
Save noelbk/9f83e5ccf82d60bac19e to your computer and use it in GitHub Desktop.
in /usr/lib64/python2.7/site-packages/MySQLdb/connections.py, line 17:
def defaulterrorhandler(connection, cursor, errorclass, errorvalue):
"""
If cursor is not None, (errorclass, errorvalue) is appended to
cursor.messages; otherwise it is appended to
connection.messages. Then errorclass is raised with errorvalue as
the value.
You can override this with your own error handler by assigning it
to the instance.
"""
error = errorclass, errorvalue
if cursor:
cursor.messages.append(error)
else:
connection.messages.append(error)
# DEBUG - show who's holding the lock
c = cursor
if c:
m = c.messages
else:
c = connection.cursor()
m = connection.messages
sql = "SHOW ENGINE INNODB STATUS"
m.append(sql)
for result in c.execute(sql):
m.append(str(result))
del cursor
del connection
raise errorclass, errorvalue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment