From 189cb2800fbc8b26af89b1316f05e64d629e1bae Mon Sep 17 00:00:00 2001 From: Adrian Holovaty Date: Fri, 30 Dec 2005 23:21:02 +0000 Subject: [PATCH] magic-removal: Added 'dummy' database backend, which is used as a fallback if DATABASE_ENGINE isn't set git-svn-id: http://code.djangoproject.com/svn/django/branches/magic-removal@1803 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/db/__init__.py | 3 +- django/db/backends/dummy/__init__.py | 0 django/db/backends/dummy/base.py | 36 +++++++++++++++++++++++ django/db/backends/dummy/creation.py | 1 + django/db/backends/dummy/introspection.py | 7 +++++ 5 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 django/db/backends/dummy/__init__.py create mode 100644 django/db/backends/dummy/base.py create mode 100644 django/db/backends/dummy/creation.py create mode 100644 django/db/backends/dummy/introspection.py diff --git a/django/db/__init__.py b/django/db/__init__.py index ae048766ff..76781e5347 100644 --- a/django/db/__init__.py +++ b/django/db/__init__.py @@ -3,8 +3,7 @@ from django.conf.settings import DATABASE_ENGINE __all__ = ('backend', 'connection', 'DatabaseError') if not DATABASE_ENGINE: - from django.core.exceptions import ImproperlyConfigured - raise ImproperlyConfigured, "You haven't set the DATABASE_ENGINE setting yet." + DATABASE_ENGINE = 'dummy' try: backend = __import__('django.db.backends.%s.base' % DATABASE_ENGINE, '', '', ['']) diff --git a/django/db/backends/dummy/__init__.py b/django/db/backends/dummy/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/django/db/backends/dummy/base.py b/django/db/backends/dummy/base.py new file mode 100644 index 0000000000..17ef35a4a2 --- /dev/null +++ b/django/db/backends/dummy/base.py @@ -0,0 +1,36 @@ +""" +Dummy database backend for Django. + +Django uses this if the DATABASE_ENGINE setting is empty (None or empty string). + +Each of these API functions, except connection.close(), raises +ImproperlyConfigured. +""" + +from django.core.exceptions import ImproperlyConfigured + +def complain(*args, **kwargs): + raise ImproperlyConfigured, "You haven't set the DATABASE_ENGINE setting yet." + +class DatabaseError(Exception): + pass + +class DatabaseWrapper: + cursor = complain + commit = complain + rollback = complain + + def close(self): + pass # close() + +supports_constraints = False +quote_name = complain +dictfetchone = complain +dictfetchmany = complain +dictfetchall = complain +get_last_insert_id = complain +get_date_extract_sql = complain +get_date_trunc_sql = complain +get_limit_offset_sql = complain +get_random_function_sql = complain +OPERATOR_MAPPING = {} diff --git a/django/db/backends/dummy/creation.py b/django/db/backends/dummy/creation.py new file mode 100644 index 0000000000..b82c4fe568 --- /dev/null +++ b/django/db/backends/dummy/creation.py @@ -0,0 +1 @@ +DATA_TYPES = {} diff --git a/django/db/backends/dummy/introspection.py b/django/db/backends/dummy/introspection.py new file mode 100644 index 0000000000..81dc8efdf0 --- /dev/null +++ b/django/db/backends/dummy/introspection.py @@ -0,0 +1,7 @@ +from django.db.backends.dummy.base import complain + +get_table_list = complain +get_table_description = complain +get_relations = complain + +DATA_TYPES_REVERSE = {}