PDF (US Ltr)
- 4.5Mb
PDF (A4)
- 4.5Mb
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
.