| 1 |
""" |
| 2 |
Dummy database backend for Django. |
| 3 |
|
| 4 |
Django uses this if the database ENGINE setting is empty (None or empty string). |
| 5 |
|
| 6 |
Each of these API functions, except connection.close(), raise |
| 7 |
ImproperlyConfigured. |
| 8 |
""" |
| 9 |
|
| 10 |
from django.core.exceptions import ImproperlyConfigured |
| 11 |
from django.db.backends.base.base import BaseDatabaseWrapper |
| 12 |
from django.db.backends.base.client import BaseDatabaseClient |
| 13 |
from django.db.backends.base.creation import BaseDatabaseCreation |
| 14 |
from django.db.backends.base.introspection import BaseDatabaseIntrospection |
| 15 |
from django.db.backends.base.operations import BaseDatabaseOperations |
| 16 |
from django.db.backends.dummy.features import DummyDatabaseFeatures |
| 17 |
|
| 18 |
|
| 19 |
def complain(*args, **kwargs): |
| 20 |
raise ImproperlyConfigured( |
| 21 |
"settings.DATABASES is improperly configured. " |
| 22 |
"Please supply the ENGINE value. Check " |
| 23 |
"settings documentation for more details." |
| 24 |
) |
| 25 |
|
| 26 |
|
| 27 |
def ignore(*args, **kwargs): |
| 28 |
pass |
| 29 |
|
| 30 |
|
| 31 |
class DatabaseOperations(BaseDatabaseOperations): |
| 32 |
quote_name = complain |
| 33 |
|
| 34 |
|
| 35 |
class DatabaseClient(BaseDatabaseClient): |
| 36 |
runshell = complain |
| 37 |
|
| 38 |
|
| 39 |
class DatabaseCreation(BaseDatabaseCreation): |
| 40 |
create_test_db = ignore |
| 41 |
destroy_test_db = ignore |
| 42 |
serialize_db_to_string = ignore |
| 43 |
|
| 44 |
|
| 45 |
class DatabaseIntrospection(BaseDatabaseIntrospection): |
| 46 |
get_table_list = complain |
| 47 |
get_table_description = complain |
| 48 |
get_relations = complain |
| 49 |
get_indexes = complain |
| 50 |
|
| 51 |
|
| 52 |
class DatabaseWrapper(BaseDatabaseWrapper): |
| 53 |
operators = {} |
| 54 |
# Override the base class implementations with null |
| 55 |
# implementations. Anything that tries to actually |
| 56 |
# do something raises complain; anything that tries |
| 57 |
# to rollback or undo something raises ignore. |
| 58 |
_cursor = complain |
| 59 |
ensure_connection = complain |
| 60 |
_commit = complain |
| 61 |
_rollback = ignore |
| 62 |
_close = ignore |
| 63 |
_savepoint = ignore |
| 64 |
_savepoint_commit = complain |
| 65 |
_savepoint_rollback = ignore |
| 66 |
_set_autocommit = complain |
| 67 |
# Classes instantiated in __init__(). |
| 68 |
client_class = DatabaseClient |
| 69 |
creation_class = DatabaseCreation |
| 70 |
features_class = DummyDatabaseFeatures |
| 71 |
introspection_class = DatabaseIntrospection |
| 72 |
ops_class = DatabaseOperations |
| 73 |
|
| 74 |
def is_usable(self): |
| 75 |
return True |