[Tutor] Trapping warnings from MySQLdb

Tim Johnson tim at johnsons-web.com
Tue Apr 14 01:22:37 CEST 2009

FYI: Using python 2.5 with the MySQLdb module.
I need to be able to raise an exeception on a MySQL warning.

I have used my own class for years that wraps the MySQLdb module,
but never did build in a feature that would let me 'tell' my class
instances to raise an except for a warning:
I'm converting csv data into Mysql commands and executing them via
a cursor object. I instantiate a cursor that returns a tuple as:
self._rdb = self._conn.cursor() ## where self._conn is an object of the                   
                                             ## MySQdb.connect class
# And I instantiate a cursor that returns a dictionary with
self._rdb = self._conn.cursor(MySQLdb.cursors.DictCursor)

Is there a way to create a cursor that _will_ raise an exeception on a 

I have looked at the cursor.py module and was not able to find such
a feature. Any and all ideas would be appreciated. This will be very
useful to us.

More information about the Tutor mailing list