class BaseDatabaseWrapper: (source)
Known subclasses: django.db.backends.dummy.base.DatabaseWrapper
, django.db.backends.mysql.base.DatabaseWrapper
, django.db.backends.oracle.base.DatabaseWrapper
, django.db.backends.postgresql.base.DatabaseWrapper
, django.db.backends.sqlite3.base.DatabaseWrapper
Represent a database connection.
Method | __init__ |
Undocumented |
Method | __repr__ |
Undocumented |
Method | check |
Backends can override this method if they can apply constraint checking (e.g. via "SET CONSTRAINTS ALL IMMEDIATE"). Should raise an IntegrityError if any invalid foreign key references are encountered. |
Method | check |
Raise an error if the database version isn't supported by this version of Django. |
Method | check |
Undocumented |
Method | chunked |
Return a cursor that tries to avoid caching in the database (if supported by the database), otherwise return a regular cursor. |
Method | clean |
Reset the counter used to generate unique savepoint ids in this thread. |
Method | close |
Close the connection to the database. |
Method | close |
Close existing connection if it fails a health check. |
Method | close |
Close the current connection if unrecoverable errors have occurred or if it outlived its maximum age. |
Method | commit |
Commit a transaction and reset the dirty flag. |
Method | connect |
Connect to the database. Assume that the connection is closed. |
Method | constraint |
Disable foreign key constraint checking. |
Method | copy |
Return a copy of this connection. |
Method | create |
Create a cursor. Assume that a connection is established. |
Method | cursor |
Create a cursor, opening a connection if necessary. |
Method | dec |
Undocumented |
Method | disable |
Backends can implement as needed to temporarily disable foreign key constraint checking. Should return True if the constraints were disabled and will need to be reenabled. |
Method | enable |
Backends can implement as needed to re-enable foreign key constraint checking. |
Method | ensure |
Guarantee that a connection to the database is established. |
Method | ensure |
Ensure the connection's timezone is set to `self.timezone_name` and return whether it changed or not. |
Method | execute |
Return a context manager under which the wrapper is applied to suitable database query executions. |
Method | get |
Get the autocommit state. |
Method | get |
Return a dict of parameters suitable for get_new_connection. |
Method | get |
Return a tuple of the database's version. |
Method | get |
Open a connection to the database. |
Method | get |
Get the "needs rollback" flag -- for *advanced use* only. |
Method | inc |
Undocumented |
Method | init |
Initialize the database connection settings. |
Method | is |
Test if the database connection is usable. |
Method | make |
Create a cursor without debug logging. |
Method | make |
Create a cursor that logs all queries in self.queries_log. |
Method | on |
Undocumented |
Method | prepare |
Hook to do any database check or preparation, generally called before migrating a project or an app. |
Method | rollback |
Roll back a transaction and reset the dirty flag. |
Method | run |
Undocumented |
Method | savepoint |
Create a savepoint inside the current transaction. Return an identifier for the savepoint that will be used for the subsequent rollback or commit. Do nothing if savepoints are not supported. |
Method | savepoint |
Release a savepoint. Do nothing if savepoints are not supported. |
Method | savepoint |
Roll back to a savepoint. Do nothing if savepoints are not supported. |
Method | schema |
Return a new instance of this backend's SchemaEditor. |
Method | set |
Enable or disable autocommit. |
Method | set |
Set or unset the "needs rollback" flag -- for *advanced use* only. |
Method | temporary |
Context manager that ensures that a connection is established, and if it opened one, closes it to avoid leaving a dangling connection. This is useful for operations outside of the request-response cycle. |
Method | validate |
Raise an error if an atomic block is active. |
Method | validate |
Undocumented |
Method | validate |
Validate that the connection isn't accessed by another thread than the one which originally created it, unless the connection was explicitly authorized to be shared between threads (via the `inc_thread_sharing()` method)... |
Class Variable | client |
Undocumented |
Class Variable | creation |
Undocumented |
Class Variable | data |
Undocumented |
Class Variable | data |
Undocumented |
Class Variable | data |
Undocumented |
Class Variable | display |
Undocumented |
Class Variable | features |
Undocumented |
Class Variable | introspection |
Undocumented |
Class Variable | ops |
Undocumented |
Class Variable | queries |
Undocumented |
Class Variable |
|
Undocumented |
Class Variable | vendor |
Undocumented |
Instance Variable | alias |
Undocumented |
Instance Variable | atomic |
Undocumented |
Instance Variable | autocommit |
Undocumented |
Instance Variable | client |
Undocumented |
Instance Variable | close |
Undocumented |
Instance Variable | closed |
Undocumented |
Instance Variable | commit |
Undocumented |
Instance Variable | connection |
Undocumented |
Instance Variable | creation |
Undocumented |
Instance Variable | errors |
Undocumented |
Instance Variable | execute |
Undocumented |
Instance Variable | features |
Undocumented |
Instance Variable | force |
Undocumented |
Instance Variable | health |
Undocumented |
Instance Variable | health |
Undocumented |
Instance Variable | in |
Undocumented |
Instance Variable | introspection |
Undocumented |
Instance Variable | needs |
Undocumented |
Instance Variable | ops |
Undocumented |
Instance Variable | queries |
Undocumented |
Instance Variable | run |
Undocumented |
Instance Variable | run |
Undocumented |
Instance Variable | savepoint |
Undocumented |
Instance Variable | savepoint |
Undocumented |
Instance Variable | settings |
Undocumented |
Instance Variable | validation |
Undocumented |
Property | allow |
Undocumented |
Property | queries |
Undocumented |
Property | queries |
Undocumented |
Property | timezone |
Return a tzinfo of the database connection time zone. |
Property | timezone |
Name of the time zone of the database connection. |
Property | wrap |
Context manager and decorator that re-throws backend-specific database exceptions using Django's common wrappers. |
Method | _close |
Undocumented |
Method | _commit |
Undocumented |
Method | _cursor |
Undocumented |
Method | _nodb |
Return a cursor from an alternative connection to be used when there is no need to access the main database, specifically for test db creation/deletion. This also prevents the production database from being exposed to potential child threads while (or after) the test database is destroyed... |
Method | _prepare |
Validate the connection is usable and perform database cursor wrapping. |
Method | _rollback |
Undocumented |
Method | _savepoint |
Undocumented |
Method | _savepoint |
Undocumented |
Method | _savepoint |
Undocumented |
Method | _savepoint |
Undocumented |
Method | _set |
Backend-specific implementation to enable or disable autocommit. |
Instance Variable | _thread |
Undocumented |
Instance Variable | _thread |
Undocumented |
Instance Variable | _thread |
Undocumented |
django.db.backends.mysql.base.DatabaseWrapper
, django.db.backends.oracle.base.DatabaseWrapper
, django.db.backends.postgresql.base.DatabaseWrapper
, django.db.backends.sqlite3.base.DatabaseWrapper
Backends can override this method if they can apply constraint checking (e.g. via "SET CONSTRAINTS ALL IMMEDIATE"). Should raise an IntegrityError if any invalid foreign key references are encountered.
django.db.backends.postgresql.base.DatabaseWrapper
Return a cursor that tries to avoid caching in the database (if supported by the database), otherwise return a regular cursor.
Close the current connection if unrecoverable errors have occurred or if it outlived its maximum age.
django.db.backends.mysql.base.DatabaseWrapper
, django.db.backends.oracle.base.DatabaseWrapper
, django.db.backends.postgresql.base.DatabaseWrapper
, django.db.backends.sqlite3.base.DatabaseWrapper
Create a cursor. Assume that a connection is established.
django.db.backends.mysql.base.DatabaseWrapper
, django.db.backends.sqlite3.base.DatabaseWrapper
Backends can implement as needed to temporarily disable foreign key constraint checking. Should return True if the constraints were disabled and will need to be reenabled.
django.db.backends.mysql.base.DatabaseWrapper
, django.db.backends.sqlite3.base.DatabaseWrapper
Backends can implement as needed to re-enable foreign key constraint checking.
django.db.backends.postgresql.base.DatabaseWrapper
Ensure the connection's timezone is set to `self.timezone_name` and return whether it changed or not.
django.db.backends.mysql.base.DatabaseWrapper
, django.db.backends.oracle.base.DatabaseWrapper
, django.db.backends.postgresql.base.DatabaseWrapper
, django.db.backends.sqlite3.base.DatabaseWrapper
Return a dict of parameters suitable for get_new_connection.
django.db.backends.mysql.base.DatabaseWrapper
, django.db.backends.oracle.base.DatabaseWrapper
, django.db.backends.postgresql.base.DatabaseWrapper
, django.db.backends.sqlite3.base.DatabaseWrapper
Return a tuple of the database's version.
django.db.backends.mysql.base.DatabaseWrapper
, django.db.backends.oracle.base.DatabaseWrapper
, django.db.backends.postgresql.base.DatabaseWrapper
, django.db.backends.sqlite3.base.DatabaseWrapper
Open a connection to the database.
django.db.backends.mysql.base.DatabaseWrapper
, django.db.backends.oracle.base.DatabaseWrapper
, django.db.backends.postgresql.base.DatabaseWrapper
Initialize the database connection settings.
django.db.backends.dummy.base.DatabaseWrapper
, django.db.backends.mysql.base.DatabaseWrapper
, django.db.backends.oracle.base.DatabaseWrapper
, django.db.backends.postgresql.base.DatabaseWrapper
, django.db.backends.sqlite3.base.DatabaseWrapper
Test if the database connection is usable. This method may assume that self.connection is not None. Actual implementations should take care not to raise exceptions as that may prevent Django from recycling unusable connections.
django.db.backends.postgresql.base.DatabaseWrapper
Create a cursor that logs all queries in self.queries_log.
django.contrib.gis.db.backends.postgis.base.DatabaseWrapper
, django.contrib.gis.db.backends.spatialite.base.DatabaseWrapper
Hook to do any database check or preparation, generally called before migrating a project or an app.
Create a savepoint inside the current transaction. Return an identifier for the savepoint that will be used for the subsequent rollback or commit. Do nothing if savepoints are not supported.
Enable or disable autocommit. The usual way to start a transaction is to turn autocommit off. SQLite does not properly start a transaction when disabling autocommit. To avoid this buggy behavior and to actually enter a new transaction, an explicit BEGIN is required. Using force_begin_transaction_with_broken_autocommit=True will issue an explicit BEGIN with SQLite. This option will be ignored for other backends.
Context manager that ensures that a connection is established, and if it opened one, closes it to avoid leaving a dangling connection. This is useful for operations outside of the request-response cycle. Provide a cursor: with self.temporary_connection() as cursor: ...
Validate that the connection isn't accessed by another thread than the one which originally created it, unless the connection was explicitly authorized to be shared between threads (via the `inc_thread_sharing()` method). Raise an exception if the validation fails.
django.db.backends.postgresql.base.DatabaseWrapper
, django.db.backends.sqlite3.base.DatabaseWrapper
Undocumented
Return a tzinfo of the database connection time zone. This is only used when time zone support is enabled. When a datetime is read from the database, it is always returned in this time zone. When the database backend supports time zones, it doesn't matter which time zone Django uses, as long as aware datetimes are used everywhere. Other users connecting to the database can choose their own time zone. When the database backend doesn't support time zones, the time zone Django uses may be constrained by the requirements of other users of the database.
Context manager and decorator that re-throws backend-specific database exceptions using Django's common wrappers.
django.db.backends.postgresql.base.DatabaseWrapper
Return a cursor from an alternative connection to be used when there is no need to access the main database, specifically for test db creation/deletion. This also prevents the production database from being exposed to potential child threads while (or after) the test database is destroyed. Refs #10868, #17786, #16969.
django.db.backends.mysql.base.DatabaseWrapper
, django.db.backends.oracle.base.DatabaseWrapper
, django.db.backends.postgresql.base.DatabaseWrapper
, django.db.backends.sqlite3.base.DatabaseWrapper
Backend-specific implementation to enable or disable autocommit.