2006-05-02 09:31:56 +08:00
|
|
|
"""
|
|
|
|
Dummy database backend for Django.
|
|
|
|
|
2009-12-22 23:18:51 +08:00
|
|
|
Django uses this if the database ENGINE setting is empty (None or empty string).
|
2006-05-02 09:31:56 +08:00
|
|
|
|
|
|
|
Each of these API functions, except connection.close(), raises
|
|
|
|
ImproperlyConfigured.
|
|
|
|
"""
|
|
|
|
|
|
|
|
from django.core.exceptions import ImproperlyConfigured
|
2008-08-11 20:11:25 +08:00
|
|
|
from django.db.backends import *
|
|
|
|
from django.db.backends.creation import BaseDatabaseCreation
|
2006-05-02 09:31:56 +08:00
|
|
|
|
|
|
|
def complain(*args, **kwargs):
|
2010-01-11 02:36:20 +08:00
|
|
|
raise ImproperlyConfigured("You haven't set the database ENGINE setting yet.")
|
2006-05-02 09:31:56 +08:00
|
|
|
|
2007-06-02 00:30:38 +08:00
|
|
|
def ignore(*args, **kwargs):
|
|
|
|
pass
|
|
|
|
|
2006-05-02 09:31:56 +08:00
|
|
|
class DatabaseError(Exception):
|
|
|
|
pass
|
|
|
|
|
2007-04-25 18:18:56 +08:00
|
|
|
class IntegrityError(DatabaseError):
|
|
|
|
pass
|
|
|
|
|
2007-08-26 02:27:57 +08:00
|
|
|
class DatabaseOperations(BaseDatabaseOperations):
|
|
|
|
quote_name = complain
|
2007-08-20 06:29:57 +08:00
|
|
|
|
2008-08-11 20:11:25 +08:00
|
|
|
class DatabaseClient(BaseDatabaseClient):
|
|
|
|
runshell = complain
|
2009-03-12 16:52:42 +08:00
|
|
|
|
2008-08-11 20:11:25 +08:00
|
|
|
class DatabaseIntrospection(BaseDatabaseIntrospection):
|
|
|
|
get_table_list = complain
|
|
|
|
get_table_description = complain
|
|
|
|
get_relations = complain
|
|
|
|
get_indexes = complain
|
2009-03-12 16:52:42 +08:00
|
|
|
|
2011-02-14 08:07:09 +08:00
|
|
|
class DatabaseWrapper(BaseDatabaseWrapper):
|
2007-08-20 11:26:55 +08:00
|
|
|
operators = {}
|
2011-02-14 08:07:09 +08:00
|
|
|
# Override the base class implementations with null
|
|
|
|
# implementations. Anything that tries to actually
|
|
|
|
# do something raises complain; anything that tries
|
|
|
|
# to rollback or undo something raises ignore.
|
2006-05-02 09:31:56 +08:00
|
|
|
_commit = complain
|
2007-06-02 00:30:38 +08:00
|
|
|
_rollback = ignore
|
2011-02-14 08:07:09 +08:00
|
|
|
enter_transaction_management = complain
|
|
|
|
leave_transaction_management = ignore
|
|
|
|
set_dirty = complain
|
|
|
|
set_clean = complain
|
|
|
|
commit_unless_managed = complain
|
|
|
|
rollback_unless_managed = ignore
|
|
|
|
savepoint = ignore
|
|
|
|
savepoint_commit = complain
|
|
|
|
savepoint_rollback = ignore
|
|
|
|
close = ignore
|
|
|
|
cursor = complain
|
|
|
|
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
|
super(DatabaseWrapper, self).__init__(*args, **kwargs)
|
2006-05-02 09:31:56 +08:00
|
|
|
|
2010-10-11 20:55:17 +08:00
|
|
|
self.features = BaseDatabaseFeatures(self)
|
2008-08-11 20:11:25 +08:00
|
|
|
self.ops = DatabaseOperations()
|
2009-03-11 11:39:34 +08:00
|
|
|
self.client = DatabaseClient(self)
|
2008-08-11 20:11:25 +08:00
|
|
|
self.creation = BaseDatabaseCreation(self)
|
|
|
|
self.introspection = DatabaseIntrospection(self)
|
2009-12-24 13:57:43 +08:00
|
|
|
self.validation = BaseDatabaseValidation(self)
|