130 lines
4.8 KiB
Plaintext
130 lines
4.8 KiB
Plaintext
|
|
{
|
||
|
|
"cells": [
|
||
|
|
{
|
||
|
|
"cell_type": "code",
|
||
|
|
"execution_count": null,
|
||
|
|
"metadata": {},
|
||
|
|
"outputs": [],
|
||
|
|
"source": [
|
||
|
|
"class Warning(Exception):\n",
|
||
|
|
" \"\"\"\n",
|
||
|
|
" Exception raised for important warnings like data truncations while inserting, etc.\n",
|
||
|
|
" \"\"\"\n",
|
||
|
|
" def __init__(self, message, *args):\n",
|
||
|
|
" self.message = message\n",
|
||
|
|
" super(Warning, self).__init__(message, *args)\n",
|
||
|
|
"\n",
|
||
|
|
"\n",
|
||
|
|
"class Error(Exception):\n",
|
||
|
|
" \"\"\"\n",
|
||
|
|
" Exception that is the base class of all other error exceptions.\n",
|
||
|
|
" You can use this to catch all errors with one single except statement.\n",
|
||
|
|
" Warnings are not considered errors and thus should not use this class as base.\n",
|
||
|
|
" \"\"\"\n",
|
||
|
|
" def __init__(self, message, *args):\n",
|
||
|
|
" self.message = message\n",
|
||
|
|
" super(Error, self).__init__(message, *args)\n",
|
||
|
|
"\n",
|
||
|
|
"\n",
|
||
|
|
"class InterfaceError(Error):\n",
|
||
|
|
" \"\"\"\n",
|
||
|
|
" Exception raised for errors that are related to the database interface rather than the database itself.\n",
|
||
|
|
" \"\"\"\n",
|
||
|
|
" def __init__(self, message, *args):\n",
|
||
|
|
" self.message = message\n",
|
||
|
|
" super(InterfaceError, self).__init__(message, *args)\n",
|
||
|
|
"\n",
|
||
|
|
"\n",
|
||
|
|
"class DatabaseError(Error):\n",
|
||
|
|
" \"\"\"\n",
|
||
|
|
" Exception raised for errors that are related to the database.\n",
|
||
|
|
" \"\"\"\n",
|
||
|
|
" def __init__(self, message, *args):\n",
|
||
|
|
" self.message = message\n",
|
||
|
|
" super(DatabaseError, self).__init__(message, *args)\n",
|
||
|
|
"\n",
|
||
|
|
"\n",
|
||
|
|
"class DataError(DatabaseError):\n",
|
||
|
|
" \"\"\"\n",
|
||
|
|
" Exception raised for errors that are due to problems with the processed data like division by zero,\n",
|
||
|
|
" numeric value out of range, etc.\n",
|
||
|
|
" \"\"\"\n",
|
||
|
|
" def __init__(self, message, *args):\n",
|
||
|
|
" self.message = message\n",
|
||
|
|
" super(DataError, self).__init__(message, *args)\n",
|
||
|
|
"\n",
|
||
|
|
"\n",
|
||
|
|
"class OperationalError(DatabaseError):\n",
|
||
|
|
" \"\"\"\n",
|
||
|
|
" Exception raised for errors that are related to the database's operation and not necessarily under\n",
|
||
|
|
" the control of the programmer, e.g. an unexpected disconnect occurs, the data source name is not found,\n",
|
||
|
|
" a transaction could not be processed, a memory allocation error occurred during processing, etc.\n",
|
||
|
|
" \"\"\"\n",
|
||
|
|
" def __init__(self, message, *args):\n",
|
||
|
|
" self.message = message\n",
|
||
|
|
" super(OperationalError, self).__init__(message, *args)\n",
|
||
|
|
"\n",
|
||
|
|
"\n",
|
||
|
|
"class IntegrityError(DatabaseError):\n",
|
||
|
|
" \"\"\"\n",
|
||
|
|
" Exception raised when the relational integrity of the database is affected, e.g. a foreign key check fails.\n",
|
||
|
|
" \"\"\"\n",
|
||
|
|
" def __init__(self, message, *args):\n",
|
||
|
|
" self.message = message\n",
|
||
|
|
" super(IntegrityError, self).__init__(message, *args)\n",
|
||
|
|
"\n",
|
||
|
|
"\n",
|
||
|
|
"class InternalError(DatabaseError):\n",
|
||
|
|
" \"\"\"\n",
|
||
|
|
" Exception raised when the database encounters an internal error, e.g. the cursor is not valid anymore,\n",
|
||
|
|
" the transaction is out of sync, etc.\n",
|
||
|
|
" \"\"\"\n",
|
||
|
|
" def __init__(self, message, *args):\n",
|
||
|
|
" self.message = message\n",
|
||
|
|
" super(InternalError, self).__init__(message, *args)\n",
|
||
|
|
"\n",
|
||
|
|
"\n",
|
||
|
|
"class ProgrammingError(DatabaseError):\n",
|
||
|
|
" \"\"\"\n",
|
||
|
|
" Exception raised for programming errors, e.g. table not found or already exists, syntax error in the SQL statement,\n",
|
||
|
|
" wrong number of parameters specified, etc.\n",
|
||
|
|
" \"\"\"\n",
|
||
|
|
" def __init__(self, message, *args):\n",
|
||
|
|
" self.message = message\n",
|
||
|
|
" super(ProgrammingError, self).__init__(message, *args)\n",
|
||
|
|
"\n",
|
||
|
|
"\n",
|
||
|
|
"class NotSupportedError(DatabaseError):\n",
|
||
|
|
" \"\"\"\n",
|
||
|
|
" Exception raised in case a method or database API was used which is not supported by the database,\n",
|
||
|
|
" e.g. requesting a .rollback() on a connection that does not support transaction or has transactions turned off.\n",
|
||
|
|
" \"\"\"\n",
|
||
|
|
" def __init__(self, message, *args):\n",
|
||
|
|
" self.message = message\n",
|
||
|
|
" super(NotSupportedError, self).__init__(message, *args)\n"
|
||
|
|
]
|
||
|
|
}
|
||
|
|
],
|
||
|
|
"metadata": {
|
||
|
|
"kernelspec": {
|
||
|
|
"display_name": "Python 3",
|
||
|
|
"language": "python",
|
||
|
|
"name": "python3"
|
||
|
|
},
|
||
|
|
"language_info": {
|
||
|
|
"codemirror_mode": {
|
||
|
|
"name": "ipython",
|
||
|
|
"version": 3
|
||
|
|
},
|
||
|
|
"file_extension": ".py",
|
||
|
|
"mimetype": "text/x-python",
|
||
|
|
"name": "python",
|
||
|
|
"nbconvert_exporter": "python",
|
||
|
|
"pygments_lexer": "ipython3",
|
||
|
|
"version": "3.7.4"
|
||
|
|
}
|
||
|
|
},
|
||
|
|
"nbformat": 4,
|
||
|
|
"nbformat_minor": 2
|
||
|
|
}
|