You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

base.py 2.2KB

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