Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1"""Exception classes for _mysql and MySQLdb. 

2 

3These classes are dictated by the DB API v2.0: 

4 

5 https://www.python.org/dev/peps/pep-0249/ 

6""" 

7 

8 

9class MySQLError(Exception): 

10 """Exception related to operation with MySQL.""" 

11 

12 

13class Warning(Warning, MySQLError): 

14 """Exception raised for important warnings like data truncations 

15 while inserting, etc.""" 

16 

17 

18class Error(MySQLError): 

19 """Exception that is the base class of all other error exceptions 

20 (not Warning).""" 

21 

22 

23class InterfaceError(Error): 

24 """Exception raised for errors that are related to the database 

25 interface rather than the database itself.""" 

26 

27 

28class DatabaseError(Error): 

29 """Exception raised for errors that are related to the 

30 database.""" 

31 

32 

33class DataError(DatabaseError): 

34 """Exception raised for errors that are due to problems with the 

35 processed data like division by zero, numeric value out of range, 

36 etc.""" 

37 

38 

39class OperationalError(DatabaseError): 

40 """Exception raised for errors that are related to the database's 

41 operation and not necessarily under the control of the programmer, 

42 e.g. an unexpected disconnect occurs, the data source name is not 

43 found, a transaction could not be processed, a memory allocation 

44 error occurred during processing, etc.""" 

45 

46 

47class IntegrityError(DatabaseError): 

48 """Exception raised when the relational integrity of the database 

49 is affected, e.g. a foreign key check fails, duplicate key, 

50 etc.""" 

51 

52 

53class InternalError(DatabaseError): 

54 """Exception raised when the database encounters an internal 

55 error, e.g. the cursor is not valid anymore, the transaction is 

56 out of sync, etc.""" 

57 

58 

59class ProgrammingError(DatabaseError): 

60 """Exception raised for programming errors, e.g. table not found 

61 or already exists, syntax error in the SQL statement, wrong number 

62 of parameters specified, etc.""" 

63 

64 

65class NotSupportedError(DatabaseError): 

66 """Exception raised in case a method or database API was used 

67 which is not supported by the database, e.g. requesting a 

68 .rollback() on a connection that does not support transaction or 

69 has transactions turned off."""