_exceptions.py 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. """Exception classes for _mysql and MySQLdb.
  2. These classes are dictated by the DB API v2.0:
  3. https://www.python.org/dev/peps/pep-0249/
  4. """
  5. class MySQLError(Exception):
  6. """Exception related to operation with MySQL."""
  7. __module__ = "MySQLdb"
  8. class Warning(Warning, MySQLError):
  9. """Exception raised for important warnings like data truncations
  10. while inserting, etc."""
  11. __module__ = "MySQLdb"
  12. class Error(MySQLError):
  13. """Exception that is the base class of all other error exceptions
  14. (not Warning)."""
  15. __module__ = "MySQLdb"
  16. class InterfaceError(Error):
  17. """Exception raised for errors that are related to the database
  18. interface rather than the database itself."""
  19. __module__ = "MySQLdb"
  20. class DatabaseError(Error):
  21. """Exception raised for errors that are related to the
  22. database."""
  23. __module__ = "MySQLdb"
  24. class DataError(DatabaseError):
  25. """Exception raised for errors that are due to problems with the
  26. processed data like division by zero, numeric value out of range,
  27. etc."""
  28. __module__ = "MySQLdb"
  29. class OperationalError(DatabaseError):
  30. """Exception raised for errors that are related to the database's
  31. operation and not necessarily under the control of the programmer,
  32. e.g. an unexpected disconnect occurs, the data source name is not
  33. found, a transaction could not be processed, a memory allocation
  34. error occurred during processing, etc."""
  35. __module__ = "MySQLdb"
  36. class IntegrityError(DatabaseError):
  37. """Exception raised when the relational integrity of the database
  38. is affected, e.g. a foreign key check fails, duplicate key,
  39. etc."""
  40. __module__ = "MySQLdb"
  41. class InternalError(DatabaseError):
  42. """Exception raised when the database encounters an internal
  43. error, e.g. the cursor is not valid anymore, the transaction is
  44. out of sync, etc."""
  45. __module__ = "MySQLdb"
  46. class ProgrammingError(DatabaseError):
  47. """Exception raised for programming errors, e.g. table not found
  48. or already exists, syntax error in the SQL statement, wrong number
  49. of parameters specified, etc."""
  50. __module__ = "MySQLdb"
  51. class NotSupportedError(DatabaseError):
  52. """Exception raised in case a method or database API was used
  53. which is not supported by the database, e.g. requesting a
  54. .rollback() on a connection that does not support transaction or
  55. has transactions turned off."""
  56. __module__ = "MySQLdb"