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


MySQL Connector/Python Developer Guide  /  ...  /  errors.ProgrammingError Exception

10.12.11 errors.ProgrammingError Exception

This exception is raised on programming errors, for example when you have a syntax error in your SQL or a table was not found.

The following example shows how to handle syntax errors:

try:
  cursor.execute("CREATE DESK t1 (id int, PRIMARY KEY (id))")
except mysql.connector.ProgrammingError as err:
  if err.errno == errorcode.ER_SYNTAX_ERROR:
    print("Check your syntax!")
  else:
    print("Error: {}".format(err))

errors.ProgrammingError is a subclass of errors.DatabaseError.


User Comments
Sign Up Login You must be logged in to post a comment.