MySQL Connector/Python Developer Guide / ... / Connector/Python API Reference / Errors and Exceptions / 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 oferrors.DatabaseError.