diff options
| author | Tim Graham <timograham@gmail.com> | 2015-01-12 15:20:40 -0500 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2015-01-14 14:16:20 -0500 |
| commit | 28308078f397d1de36fd0da417ac7da2544ba12d (patch) | |
| tree | 80207ff582b2350d058c1c7c49072b761391c04f /django/db/backends/postgresql_psycopg2/base.py | |
| parent | 737d24923ac69bb8b89af1bb2f3f4c4c744349e8 (diff) | |
Fixed #22603 -- Reorganized classes in django.db.backends.
Diffstat (limited to 'django/db/backends/postgresql_psycopg2/base.py')
| -rw-r--r-- | django/db/backends/postgresql_psycopg2/base.py | 54 |
1 files changed, 12 insertions, 42 deletions
diff --git a/django/db/backends/postgresql_psycopg2/base.py b/django/db/backends/postgresql_psycopg2/base.py index 8b45b5d73e..34b2870773 100644 --- a/django/db/backends/postgresql_psycopg2/base.py +++ b/django/db/backends/postgresql_psycopg2/base.py @@ -5,19 +5,11 @@ Requires psycopg 2: http://initd.org/projects/psycopg2 """ from django.conf import settings -from django.db.backends import (BaseDatabaseFeatures, BaseDatabaseWrapper, - BaseDatabaseValidation) -from django.db.backends.postgresql_psycopg2.operations import DatabaseOperations -from django.db.backends.postgresql_psycopg2.client import DatabaseClient -from django.db.backends.postgresql_psycopg2.creation import DatabaseCreation -from django.db.backends.postgresql_psycopg2.version import get_version -from django.db.backends.postgresql_psycopg2.introspection import DatabaseIntrospection -from django.db.backends.postgresql_psycopg2.schema import DatabaseSchemaEditor -from django.db.utils import InterfaceError +from django.db.backends.base.base import BaseDatabaseWrapper +from django.db.backends.base.validation import BaseDatabaseValidation from django.utils.encoding import force_str from django.utils.functional import cached_property from django.utils.safestring import SafeText, SafeBytes -from django.utils.timezone import utc try: import psycopg2 as Database @@ -27,6 +19,16 @@ except ImportError as e: from django.core.exceptions import ImproperlyConfigured raise ImproperlyConfigured("Error loading psycopg2 module: %s" % e) +# Some of these import psycopg2, so import them after checking if it's installed. +from .client import DatabaseClient +from .creation import DatabaseCreation +from .features import DatabaseFeatures +from .introspection import DatabaseIntrospection +from .operations import DatabaseOperations +from .schema import DatabaseSchemaEditor +from .utils import utc_tzinfo_factory +from .version import get_version + DatabaseError = Database.DatabaseError IntegrityError = Database.IntegrityError @@ -37,38 +39,6 @@ psycopg2.extensions.register_adapter(SafeText, psycopg2.extensions.QuotedString) psycopg2.extras.register_uuid() -def utc_tzinfo_factory(offset): - if offset != 0: - raise AssertionError("database connection isn't set to UTC") - return utc - - -class DatabaseFeatures(BaseDatabaseFeatures): - needs_datetime_string_cast = False - can_return_id_from_insert = True - has_real_datatype = True - has_native_duration_field = True - driver_supports_timedelta_args = True - can_defer_constraint_checks = True - has_select_for_update = True - has_select_for_update_nowait = True - has_bulk_insert = True - uses_savepoints = True - can_release_savepoints = True - supports_tablespaces = True - supports_transactions = True - can_introspect_autofield = True - can_introspect_ip_address_field = True - can_introspect_small_integer_field = True - can_distinct_on_fields = True - can_rollback_ddl = True - supports_combined_alters = True - nulls_order_largest = True - closed_cursor_error_class = InterfaceError - has_case_insensitive_like = False - requires_sqlparse_for_splitting = False - - class DatabaseWrapper(BaseDatabaseWrapper): vendor = 'postgresql' # This dictionary maps Field objects to their associated PostgreSQL column |
