diff --git a/django/db/backends/postgresql_psycopg2/base.py b/django/db/backends/postgresql_psycopg2/base.py
index 61be680..e99fcc7 100644
a
|
b
|
psycopg2.extensions.register_type(psycopg2.extensions.UNICODE)
|
31 | 31 | psycopg2.extensions.register_adapter(SafeString, psycopg2.extensions.QuotedString) |
32 | 32 | psycopg2.extensions.register_adapter(SafeUnicode, psycopg2.extensions.QuotedString) |
33 | 33 | |
| 34 | utils.IntegrityError.register(Database.IntegrityError) |
| 35 | utils.DatabaseError.register(Database.DatabaseError) |
| 36 | |
34 | 37 | logger = getLogger('django.db.backends') |
35 | 38 | |
36 | 39 | def utc_tzinfo_factory(offset): |
… |
… |
class CursorWrapper(object):
|
47 | 50 | def __init__(self, cursor): |
48 | 51 | self.cursor = cursor |
49 | 52 | |
50 | | def execute(self, query, args=None): |
51 | | try: |
52 | | return self.cursor.execute(query, args) |
53 | | except Database.IntegrityError as e: |
54 | | raise utils.IntegrityError, utils.IntegrityError(*tuple(e)), sys.exc_info()[2] |
55 | | except Database.DatabaseError as e: |
56 | | raise utils.DatabaseError, utils.DatabaseError(*tuple(e)), sys.exc_info()[2] |
57 | | |
58 | | def executemany(self, query, args): |
59 | | try: |
60 | | return self.cursor.executemany(query, args) |
61 | | except Database.IntegrityError as e: |
62 | | raise utils.IntegrityError, utils.IntegrityError(*tuple(e)), sys.exc_info()[2] |
63 | | except Database.DatabaseError as e: |
64 | | raise utils.DatabaseError, utils.DatabaseError(*tuple(e)), sys.exc_info()[2] |
65 | | |
66 | 53 | def __getattr__(self, attr): |
67 | 54 | if attr in self.__dict__: |
68 | 55 | return self.__dict__[attr] |
diff --git a/django/db/utils.py b/django/db/utils.py
index 2b6ae2c..52f8188 100644
a
|
b
|
|
1 | 1 | import os |
2 | 2 | from threading import local |
3 | 3 | |
| 4 | from abc import ABCMeta |
| 5 | |
4 | 6 | from django.conf import settings |
5 | 7 | from django.core.exceptions import ImproperlyConfigured |
6 | 8 | from django.utils.importlib import import_module |
… |
… |
DEFAULT_DB_ALIAS = 'default'
|
12 | 14 | # We will rethrow any backend-specific errors using these |
13 | 15 | # common wrappers |
14 | 16 | class DatabaseError(Exception): |
15 | | pass |
| 17 | __metaclass__ = ABCMeta |
16 | 18 | |
17 | 19 | class IntegrityError(DatabaseError): |
18 | | pass |
| 20 | __metaclass__ = ABCMeta |
19 | 21 | |
20 | 22 | |
21 | 23 | def load_backend(backend_name): |