Documentation Home
MySQL Connector/Python Developer Guide
Related Documentation Download this Manual
PDF (US Ltr) - 0.6Mb
PDF (A4) - 0.6Mb
HTML Download (TGZ) - 82.9Kb
HTML Download (Zip) - 95.5Kb


MySQL Connector/Python Developer Guide  /  ...  /  MySQLCursor.fetchwarnings() Method

10.5.9 MySQLCursor.fetchwarnings() Method

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's get_warnings property.

The following example shows a SELECT 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's raise_on_warnings property.


User Comments
User comments in this section are, as the name implies, provided by MySQL users. The MySQL documentation team is not responsible for, nor do they endorse, any of the information provided here.
Sign Up Login You must be logged in to post a comment.