diff options
Diffstat (limited to 'django/db/backends/postgresql_psycopg2/base.py')
| -rw-r--r-- | django/db/backends/postgresql_psycopg2/base.py | 34 |
1 files changed, 3 insertions, 31 deletions
diff --git a/django/db/backends/postgresql_psycopg2/base.py b/django/db/backends/postgresql_psycopg2/base.py index c0ecbf80e9..dcf9f01759 100644 --- a/django/db/backends/postgresql_psycopg2/base.py +++ b/django/db/backends/postgresql_psycopg2/base.py @@ -4,7 +4,7 @@ PostgreSQL database backend for Django. Requires psycopg 2: http://initd.org/projects/psycopg2 """ -from django.db.backends import util +from django.db.backends import BaseDatabaseWrapper, util try: import psycopg2 as Database import psycopg2.extensions @@ -15,25 +15,12 @@ except ImportError, e: DatabaseError = Database.DatabaseError IntegrityError = Database.IntegrityError -try: - # Only exists in Python 2.4+ - from threading import local -except ImportError: - # Import copy of _thread_local.py from Python 2.4 - from django.utils._threading_local import local - psycopg2.extensions.register_type(psycopg2.extensions.UNICODE) postgres_version = None -class DatabaseWrapper(local): - def __init__(self, **kwargs): - self.connection = None - self.queries = [] - self.options = kwargs - - def cursor(self): - from django.conf import settings +class DatabaseWrapper(BaseDatabaseWrapper): + def _cursor(self, settings): set_tz = False if self.connection is None: set_tz = True @@ -60,23 +47,8 @@ class DatabaseWrapper(local): if not postgres_version: cursor.execute("SELECT version()") postgres_version = [int(val) for val in cursor.fetchone()[0].split()[1].split('.')] - if settings.DEBUG: - return util.CursorDebugWrapper(cursor, self) return cursor - def _commit(self): - if self.connection is not None: - return self.connection.commit() - - def _rollback(self): - if self.connection is not None: - return self.connection.rollback() - - def close(self): - if self.connection is not None: - self.connection.close() - self.connection = None - allows_group_by_ordinal = True allows_unique_and_pk = True autoindexes_primary_keys = True |
