[+/-]
errorcodeerrors.Errorerrors.Warningerrors.InterfaceErrorerrors.DatabaseErrorerrors.InternalErrorerrors.OperationalErrorerrors.ProgrammingErrorerrors.IntegrityErrorerrors.DataErrorerrors.NotSupportedErrorerrors.custom_error_exception(error=None,
exception=None)
The mysql.connector.errors module defines
exception classes for errors and warnings raised by MySQL
Connector/Python. Most classes defined in this module are
available when you import mysql.connector.
The exception classes defined in this module mostly follow the Python Database Specification v2.0 (PEP-249). For some MySQL client or server errors it is not always clear which exception to raise. It is good to discuss whether an error should be reclassified by opening a bug report.
MySQL Server errors are mapped with Python exception based on
their SQLSTATE value (see
Server Error Codes and Messages). The following table
shows the SQLSTATE classes and the exception Connector/Python
raises. It is, however, possible to redefine which exception is
raised for each server error. Note that the default exception is
DatabaseError.
Table 8.1.
| SQLSTATE Class | Connector/Python Exception |
|---|---|
02 | DataError |
02 | DataError |
07 | DatabaseError |
08 | OperationalError |
0A | NotSupportedError |
21 | DataError |
22 | DataError |
23 | IntegrityError |
24 | ProgrammingError |
25 | ProgrammingError |
26 | ProgrammingError |
27 | ProgrammingError |
28 | ProgrammingError |
2A | ProgrammingError |
2B | DatabaseError |
2C | ProgrammingError |
2D | DatabaseError |
2E | DatabaseError |
33 | DatabaseError |
34 | ProgrammingError |
35 | ProgrammingError |
37 | ProgrammingError |
3C | ProgrammingError |
3D | ProgrammingError |
3F | ProgrammingError |
40 | InternalError |
42 | ProgrammingError |
44 | InternalError |
HZ | OperationalError |
XA | IntegrityError |
0K | OperationalError |
HY | DatabaseError |

User Comments
Add your own comment.