Documentation Home
Connectors and APIs Manual
Download this Manual
PDF (US Ltr) - 4.5Mb
PDF (A4) - 4.5Mb


6.9.5.18 MySQLCursor.warnings Property

Syntax:

Press CTRL+C to copy
tuples = cursor.warnings

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

The following example shows a SELECT statement that generates a warning:

Press CTRL+C to copy
>>> cnx.get_warnings = True >>> cursor.execute("SELECT 'a'+1") >>> cursor.fetchall() [(1.0,)] >>> print(cursor.warnings) [(u'Warning', 1292, u"Truncated incorrect DOUBLE value: 'a'")]

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