The two main errors in MySQLdb
Python generally supports several kinds of errors, and MySQL for Python is no different. The obvious difference between the two is that MySQLdb
's errors deal exclusively with the database connection. Where MySQLdb
passes warnings that are not MySQL-specific, all exceptions are related to MySQL.
The MySQL-specific exceptions are then classified as either warnings or errors. There is only one kind of warning, but MySQLdb
allows two categories of errors—DatabaseError
and InterfaceError
. Of the former, there are six types that we will discuss here.
DatabaseError
When there is a problem with the MySQL database itself, a DatabaseError
is thrown. This is an intermediate catch-all category of exceptions that deal with everything from how the data is processed (for example, errors arising from division by zero), to problems in the SQL syntax, to internal problems within MySQL itself. Essentially, if a connection is made and a problem arises, the DatabaseError
will catch...