summaryrefslogtreecommitdiff
path: root/_mysql_exceptions.py
diff options
context:
space:
mode:
authorEvax Software <contact@evax.fr>2012-10-04 13:34:39 -0400
committerfarcepest <farcepest@gmail.com>2012-10-04 13:34:39 -0400
commit7a846cf5e35ebcad852309aebaa0bac8a7244744 (patch)
tree4fbd759ae4894cabcd590e15e61b535766a13ee2 /_mysql_exceptions.py
parent0164ffeb2534f050148348e50a51641491b6a65d (diff)
downloadmysqldb1-7a846cf5e35ebcad852309aebaa0bac8a7244744.tar.gz
Allow pip install from git
Merged with modifications from https://github.com/evax/MySQLdb1/commit/a8152690101733904b16a32ff8467220ca07242c
Diffstat (limited to '_mysql_exceptions.py')
-rw-r--r--_mysql_exceptions.py87
1 files changed, 87 insertions, 0 deletions
diff --git a/_mysql_exceptions.py b/_mysql_exceptions.py
new file mode 100644
index 0000000..3241e74
--- /dev/null
+++ b/_mysql_exceptions.py
@@ -0,0 +1,87 @@
+"""_mysql_exceptions: Exception classes for _mysql and MySQLdb.
+
+These classes are dictated by the DB API v2.0:
+
+ http://www.python.org/topics/database/DatabaseAPI-2.0.html
+"""
+
+try:
+ from exceptions import Exception, StandardError, Warning
+except ImportError:
+ # Python 3
+ StandardError = Exception
+
+
+class MySQLError(StandardError):
+
+ """Exception related to operation with MySQL."""
+
+
+class Warning(Warning, MySQLError):
+
+ """Exception raised for important warnings like data truncations
+ while inserting, etc."""
+
+class Error(MySQLError):
+
+ """Exception that is the base class of all other error exceptions
+ (not Warning)."""
+
+
+class InterfaceError(Error):
+
+ """Exception raised for errors that are related to the database
+ interface rather than the database itself."""
+
+
+class DatabaseError(Error):
+
+ """Exception raised for errors that are related to the
+ database."""
+
+
+class DataError(DatabaseError):
+
+ """Exception raised for errors that are due to problems with the
+ processed data like division by zero, numeric value out of range,
+ etc."""
+
+
+class OperationalError(DatabaseError):
+
+ """Exception raised for errors that are related to the database's
+ operation and not necessarily under the control of the programmer,
+ e.g. an unexpected disconnect occurs, the data source name is not
+ found, a transaction could not be processed, a memory allocation
+ error occurred during processing, etc."""
+
+
+class IntegrityError(DatabaseError):
+
+ """Exception raised when the relational integrity of the database
+ is affected, e.g. a foreign key check fails, duplicate key,
+ etc."""
+
+
+class InternalError(DatabaseError):
+
+ """Exception raised when the database encounters an internal
+ error, e.g. the cursor is not valid anymore, the transaction is
+ out of sync, etc."""
+
+
+class ProgrammingError(DatabaseError):
+
+ """Exception raised for programming errors, e.g. table not found
+ or already exists, syntax error in the SQL statement, wrong number
+ of parameters specified, etc."""
+
+
+class NotSupportedError(DatabaseError):
+
+ """Exception raised in case a method or database API was used
+ which is not supported by the database, e.g. requesting a
+ .rollback() on a connection that does not support transaction or
+ has transactions turned off."""
+
+