diff --git a/django/db/backends/dummy/base.py b/django/db/backends/dummy/base.py index 602bfb8fe6..126083cd50 100644 --- a/django/db/backends/dummy/base.py +++ b/django/db/backends/dummy/base.py @@ -26,14 +26,6 @@ def ignore(*args, **kwargs): pass -class DatabaseError(Exception): - pass - - -class IntegrityError(DatabaseError): - pass - - class DatabaseOperations(BaseDatabaseOperations): quote_name = complain diff --git a/django/db/backends/mysql/base.py b/django/db/backends/mysql/base.py index 472b2b98df..cce3b9de99 100644 --- a/django/db/backends/mysql/base.py +++ b/django/db/backends/mysql/base.py @@ -52,10 +52,6 @@ if (version < (1, 2, 1) or ( raise ImproperlyConfigured("MySQLdb-1.2.1p2 or newer is required; you have %s" % Database.__version__) -DatabaseError = Database.DatabaseError -IntegrityError = Database.IntegrityError - - def adapt_datetime_warn_on_aware_datetime(value, conv): # Remove this function and rely on the default adapter in Django 2.0. if settings.USE_TZ and timezone.is_aware(value): diff --git a/django/db/backends/oracle/base.py b/django/db/backends/oracle/base.py index 9fafd43b34..55b75c3ef4 100644 --- a/django/db/backends/oracle/base.py +++ b/django/db/backends/oracle/base.py @@ -63,9 +63,6 @@ from .operations import DatabaseOperations # NOQA isort:skip from .schema import DatabaseSchemaEditor # NOQA isort:skip from .utils import Oracle_datetime, convert_unicode # NOQA isort:skip -DatabaseError = Database.DatabaseError -IntegrityError = Database.IntegrityError - class _UninitializedOperatorsDescriptor(object): @@ -241,7 +238,7 @@ class DatabaseWrapper(BaseDatabaseWrapper): cursor.execute("SELECT 1 FROM DUAL WHERE DUMMY %s" % self._standard_operators['contains'], ['X']) - except DatabaseError: + except Database.DatabaseError: self.operators = self._likec_operators self.pattern_ops = self._likec_pattern_ops else: @@ -479,7 +476,7 @@ class FormatStylePlaceholderCursor(object): return self.cursor.execute(query, self._param_generator(params)) except Database.DatabaseError as e: # cx_Oracle <= 4.4.0 wrongly raises a DatabaseError for ORA-01400. - if hasattr(e.args[0], 'code') and e.args[0].code == 1400 and not isinstance(e, IntegrityError): + if hasattr(e.args[0], 'code') and e.args[0].code == 1400 and not isinstance(e, Database.IntegrityError): six.reraise(utils.IntegrityError, utils.IntegrityError(*tuple(e.args)), sys.exc_info()[2]) raise @@ -498,7 +495,7 @@ class FormatStylePlaceholderCursor(object): return self.cursor.executemany(query, [self._param_generator(p) for p in formatted]) except Database.DatabaseError as e: # cx_Oracle <= 4.4.0 wrongly raises a DatabaseError for ORA-01400. - if hasattr(e.args[0], 'code') and e.args[0].code == 1400 and not isinstance(e, IntegrityError): + if hasattr(e.args[0], 'code') and e.args[0].code == 1400 and not isinstance(e, Database.IntegrityError): six.reraise(utils.IntegrityError, utils.IntegrityError(*tuple(e.args)), sys.exc_info()[2]) raise diff --git a/django/db/backends/postgresql/base.py b/django/db/backends/postgresql/base.py index 1ab05d81f6..d188f37853 100644 --- a/django/db/backends/postgresql/base.py +++ b/django/db/backends/postgresql/base.py @@ -44,9 +44,6 @@ from .schema import DatabaseSchemaEditor # NOQA isort:skip from .utils import utc_tzinfo_factory # NOQA isort:skip from .version import get_version # NOQA isort:skip -DatabaseError = Database.DatabaseError -IntegrityError = Database.IntegrityError - if six.PY2: psycopg2.extensions.register_type(psycopg2.extensions.UNICODE) psycopg2.extensions.register_type(psycopg2.extensions.UNICODEARRAY) @@ -239,7 +236,7 @@ class DatabaseWrapper(BaseDatabaseWrapper): nodb_connection = super(DatabaseWrapper, self)._nodb_connection try: nodb_connection.ensure_connection() - except (DatabaseError, WrappedDatabaseError): + except (Database.DatabaseError, WrappedDatabaseError): warnings.warn( "Normally Django will use a connection to the 'postgres' database " "to avoid running initialization queries against the production " diff --git a/django/db/backends/sqlite3/base.py b/django/db/backends/sqlite3/base.py index e8b707861f..ff78adaffa 100644 --- a/django/db/backends/sqlite3/base.py +++ b/django/db/backends/sqlite3/base.py @@ -45,9 +45,6 @@ from .introspection import DatabaseIntrospection # isort:skip from .operations import DatabaseOperations # isort:skip from .schema import DatabaseSchemaEditor # isort:skip -DatabaseError = Database.DatabaseError -IntegrityError = Database.IntegrityError - def adapt_datetime_warn_on_aware_datetime(value): # Remove this function and rely on the default adapter in Django 2.0.