From 295f00d099473bb00e5b5773291b87c72e143524 Mon Sep 17 00:00:00 2001 From: Adrian Holovaty Date: Wed, 14 Dec 2005 05:37:28 +0000 Subject: [PATCH] magic-removal: Moved django/core/db/__init__.py to django/db/__init__.py and cleaned it up git-svn-id: http://code.djangoproject.com/svn/django/branches/magic-removal@1635 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/core/db/__init__.py | 42 -------------------------------------- django/db/__init__.py | 19 +++++++++++++++++ 2 files changed, 19 insertions(+), 42 deletions(-) delete mode 100644 django/core/db/__init__.py create mode 100644 django/db/__init__.py diff --git a/django/core/db/__init__.py b/django/core/db/__init__.py deleted file mode 100644 index 5883acefdd..0000000000 --- a/django/core/db/__init__.py +++ /dev/null @@ -1,42 +0,0 @@ -""" -This is the core database connection. - -All Django code assumes database SELECT statements cast the resulting values as such: - * booleans are mapped to Python booleans - * dates are mapped to Python datetime.date objects - * times are mapped to Python datetime.time objects - * timestamps are mapped to Python datetime.datetime objects -""" - -from django.conf.settings import DATABASE_ENGINE - -try: - dbmod = __import__('django.core.db.backends.%s' % DATABASE_ENGINE, '', '', ['']) -except ImportError, exc: - # The database backend wasn't found. Display a helpful error message - # listing all possible database backends. - from django.core.exceptions import ImproperlyConfigured - import os - backend_dir = os.path.join(__path__[0], 'backends') - available_backends = [f[:-3] for f in os.listdir(backend_dir) if f.endswith('.py') and not f.startswith('__init__')] - available_backends.sort() - raise ImproperlyConfigured, "Could not load database backend: %s. Is your DATABASE_ENGINE setting (currently, %r) spelled correctly? Available options are: %s" % \ - (exc, DATABASE_ENGINE, ", ".join(map(repr, available_backends))) - -DatabaseError = dbmod.DatabaseError -db = dbmod.DatabaseWrapper() -dictfetchone = dbmod.dictfetchone -dictfetchmany = dbmod.dictfetchmany -dictfetchall = dbmod.dictfetchall -dictfetchall = dbmod.dictfetchall -get_last_insert_id = dbmod.get_last_insert_id -get_date_extract_sql = dbmod.get_date_extract_sql -get_date_trunc_sql = dbmod.get_date_trunc_sql -get_limit_offset_sql = dbmod.get_limit_offset_sql -get_random_function_sql = dbmod.get_random_function_sql -get_table_list = dbmod.get_table_list -get_table_description = dbmod.get_table_description -get_relations = dbmod.get_relations -OPERATOR_MAPPING = dbmod.OPERATOR_MAPPING -DATA_TYPES = dbmod.DATA_TYPES -DATA_TYPES_REVERSE = dbmod.DATA_TYPES_REVERSE diff --git a/django/db/__init__.py b/django/db/__init__.py new file mode 100644 index 0000000000..fde0745659 --- /dev/null +++ b/django/db/__init__.py @@ -0,0 +1,19 @@ +from django.conf.settings import DATABASE_ENGINE + +__all__ = ('backend', 'connection', 'DatabaseError') + +try: + backend = __import__('django.db.backends.%s.base' % DATABASE_ENGINE, '', '', ['']) +except ImportError, e: + # The database backend wasn't found. Display a helpful error message + # listing all possible database backends. + from django.core.exceptions import ImproperlyConfigured + import os + backend_dir = os.path.join(__path__[0], 'backends') + available_backends = [f[:-3] for f in os.listdir(backend_dir) if not f.startswith('_')] + available_backends.sort() + raise ImproperlyConfigured, "Could not load database backend: %s. Is your DATABASE_ENGINE setting (currently, %r) spelled correctly? Available options are: %s" % \ + (e, DATABASE_ENGINE, ", ".join(map(repr, available_backends))) + +connection = backend.DatabaseWrapper() +DatabaseError = dbmod.DatabaseError