Documentation Home
MySQL Connector/Python Developer Guide
Related Documentation Download this Manual
PDF (US Ltr) - 0.7Mb
PDF (A4) - 0.7Mb


10.5.14 MySQLCursor.fetchwarnings() Method

Deprecation

This method has been deprecated as of 9.3.0. Use the property methodSection 10.5.18, “MySQLCursor.warnings Property” instead.

Syntax:

tuples = cursor.fetchwarnings()

This method returns a list of tuples containing warnings generated by the previously executed operation. To set whether to fetch warnings, use the connection'sget_warnings property.

The following example shows aSELECT statement that generates a warning:

>>> cnx.get_warnings = True>>> cursor.execute("SELECT 'a'+1")>>> cursor.fetchall()[(1.0,)]>>> cursor.fetchwarnings()[(u'Warning', 1292, u"Truncated incorrect DOUBLE value: 'a'")]

When warnings are generated, it is possible to raise errors instead, using the connection'sraise_on_warnings property.