Backend
BackendImpl
BackendImpl.all_impls()
BackendImpl.create_named_database()
BackendImpl.create_opportunistic_driver_url()
BackendImpl.default_engine_kwargs
BackendImpl.dispose()
BackendImpl.drop_additional_objects()
BackendImpl.drop_all_objects()
BackendImpl.drop_named_database()
BackendImpl.impl
BackendImpl.provisioned_database_url()
BackendImpl.supports_drop_fk
BackendResource
DatabaseResource
ProvisionedDatabase
Schema
SchemaResource
AdHocDbFixture
BaseDbFixture
DeletesFromSchema
GeneratesSchema
GeneratesSchemaFromMigrations
MySQLOpportunisticFixture
OpportunisticDBTestMixin
OpportunisticDbFixture
PostgresqlOpportunisticFixture
ReplaceEngineFacadeFixture
ResetsData
SimpleDbFixture
optimize_module_test_loader()
optimize_package_test_loader()
ModelsMigrationsSync
ModelsMigrationsSync.compare_server_default()
ModelsMigrationsSync.compare_type()
ModelsMigrationsSync.db_sync()
ModelsMigrationsSync.filter_metadata_diff()
ModelsMigrationsSync.get_engine()
ModelsMigrationsSync.get_metadata()
ModelsMigrationsSync.include_object()
ModelsMigrationsSync.test_models_sync()
WalkVersionsMixin
DialectFunctionDispatcher
DialectMultiFunctionDispatcher
DialectSingleFunctionDispatcher
add_index()
change_deleted_column_type_to_boolean()
change_deleted_column_type_to_id_type()
change_index_columns()
column_exists()
dispatch_for_dialect()
drop_index()
drop_old_duplicate_entries_from_table()
get_db_connection_info()
get_foreign_key_constraint_name()
get_indexes()
get_non_innodb_tables()
get_non_ndbcluster_tables()
get_table()
get_unique_keys()
index_exists()
index_exists_on_columns()
model_query()
paginate_query()
sanitize_db_url()
suspend_fk_constraints_for_col_alter()
to_list()
A DB backend module should implement a method named ‘get_backend’ which takes no arguments. The method can return any object that implements DB API methods.
Bases: object
Initialize the chosen DB API backend.
After initialization API methods is available as normal attributes of
DBAPI
subclass. Database API methods are supposed to be called as
DBAPI instance methods.
backend_name (str) – name of the backend to load
backend_mapping (dict) – backend name -> module/class to load mapping
lazy (bool) – load the DB backend lazily on the first DB API method call
use_db_reconnect (bool) – retry DB transactions on disconnect or not
retry_interval (int) – seconds between transaction retries
inc_retry_interval (bool) – increase retry interval or not
max_retry_interval (int) – max interval value between retries
max_retries (int) – max number of retries before an error is raised
None
False
Initialize DBAPI instance given a config instance.
conf (oslo.config.cfg.ConfigOpts) – oslo.config config instance
backend_mapping (dict) – backend name -> module/class to load mapping
lazy (bool) – load the DB backend lazily on the first DB API method call
Retry a DB API call if Deadlock was received.
wrap_db_entry will be applied to all db.api functions marked with this decorator.
Retry a DB API call if RetryRequest exception was received.
wrap_db_entry will be applied to all db.api functions marked with this decorator.
Indicate api method as safe for re-connection to database.
Database connection retries will be enabled for the decorated api method. Database connection failure can have many causes, which can be temporary. In such cases retry may increase the likelihood of connection.
Usage:
@safe_for_db_retry
def api_method(self):
self.engine.connect()
f (function.) – database api method.
Bases: object
Retry db.api methods, if db_error raised
Retry decorated db.api methods. This decorator catches db_error and retries function in a loop until it succeeds, or until maximum retries count will be reached.
Keyword arguments:
retry_interval (int or float) – seconds between transaction retries
max_retries (int) – max number of retries before an error is raised
inc_retry_interval (bool) – determine increase retry interval or not
max_retry_interval (int or float) – max interval value between retries
exception_checker (callable) – checks if an exception should trigger a retry
jitter (bool) – determine increase retry interval use jitter or not, jitter is always interpreted as True for a DBDeadlockError
Bases: object
DB API wrapper class.
This wraps the oslo DB API with an option to be able to use eventlet’s thread pooling. Since the CONF variable may not be loaded at the time this class is instantiated, we must look at it on the first DB API call.
Returns a list of oslo.config options available in this module.
a list of (group_name, opts) tuples
DB related custom exceptions.
Custom exceptions intended to determine the causes of specific database errors. This module provides more generic exceptions than the database-specific driver libraries, and so users of oslo.db can catch these no matter which database the application is using. Most of the exceptions are wrappers. Wrapper exceptions take an original exception as positional argument and keep it for purposes of deeper debug.
Example:
try:
statement(arg)
except sqlalchemy.exc.OperationalError as e:
raise DBDuplicateEntry(e)
This is useful to determine more specific error cases further at execution, when you need to add some extra information to an error message. Wrapper exceptions takes care about original error message displaying to not to loose low level cause of an error. All the database api exceptions wrapped into the specific exceptions provided belove.
Please use only database related custom exceptions with database manipulations with try/except statement. This is required for consistent handling of database errors.
Bases: Exception
Error raised when a particular database backend is not available
within a test suite.
Bases: Exception
Error raised when the enginefacade cannot start up correctly.
Bases: Exception
Error raised when no column or an invalid column is found.
Bases: AttributeError
Error raised when requesting a not-setup enginefacade attribute.
This applies to the session
and connection
attributes
of a user-defined context and/or RequestContext object, when they
are accessed within the scope of an enginefacade decorator
or context manager, but the context has not requested that
attribute (e.g. like “with enginefacade.connection.using(context)”
and “context.session” is requested).
Bases: DBError
Wrapped connection specific exception.
Raised when database connection is failed.
Bases: DBError
Check constraint fails for column error.
Raised when made an attempt to write to a column a value that does not satisfy a CHECK constraint.
table (str) – the table name for which the check fails
check_name (str) – the table of the check that failed to be satisfied
Bases: DBError
Raised for errors that are due to problems with the processed data.
E.g. division by zero, numeric value out of range, incorrect data type, etc
Bases: DBError
Database dead lock error.
Deadlock is a situation that occurs when two or more different database sessions have some data locked, and each database session requests a lock on the data that another, different, session has already locked.
Bases: DBError
Duplicate entry at unique column error.
Raised when made an attempt to write to a unique column the same entry as existing one. :attr: columns available on an instance of the exception and could be used at error handling:
try:
instance_type_ref.save()
except DBDuplicateEntry as e:
if 'colname' in e.columns:
# Handle error.
columns (list) – a list of unique columns have been attempted to write a duplicate entry.
value – a value which has been attempted to write. The value will be None, if we can’t extract it for a particular database backend. Only MySQL and PostgreSQL 9.x are supported right now.
Bases: CausedByException
Base exception for all custom database exceptions.
inner_exception – an original exception which was wrapped with DBError or its subclasses.
Bases: Exception
Database unicode error.
Raised when unicode parameter is passed to a database without encoding directive.
Bases: DBError
Wrapped migration specific exception.
Raised when migrations couldn’t be completed successfully.
Bases: DBError
Constraint does not exist.
table (str) – table name
constraint – constraint name
Bases: DBError
Database does not exist.
database (str) – database name
Bases: DBError
Table does not exist.
table (str) – table name
Bases: DBError
Raised when a database backend has raised sqla.exc.NotSupportedError
Bases: DBError
Foreign key violation error.
table (str) – a table name in which the reference is directed.
constraint (str) – a problematic constraint name.
key (str) – a broken reference key name.
key_table (str) – a table name which contains the key.
Bases: Exception
A sort key destined for database query usage is invalid.
Bases: AttributeError
Error raised for enginefacade attribute access with no context.
This applies to the session
and connection
attributes
of a user-defined context and/or RequestContext object, when they
are accessed outside of the scope of an enginefacade decorator
or context manager.
The exception is a subclass of AttributeError so that
normal Python missing attribute behaviors are maintained, such
as support for getattr(context, 'session', None)
.
Bases: Exception
Error raised when DB operation needs to be retried.
That could be intentionally raised by the code without any real DB errors.
Returns a list of oslo.config options available in the library.
The returned list includes all oslo.config options which may be registered at runtime by the library.
Each element of the list is a tuple. The first element is the name of the group under which the list of elements in the second element will be registered. A group name of None corresponds to the [DEFAULT] group in config files.
The purpose of this is to allow tools like the Oslo sample config file generator to discover the options exposed to users by this library.
a list of (group_name, opts) tuples
Set defaults for configuration variables.
Overrides default options values.
conf (oslo.config.cfg.ConfigOpts instance.) – Config instance specified to set default options in it. Using of instances instead of a global config object prevents conflicts between options declaration.
connection (str) – SQL connection string. Valid SQLite URL forms are: * sqlite:///:memory: (or, sqlite://) * sqlite:///relative/path/to/file.db * sqlite:////absolute/path/to/file.db
max_pool_size (int) – maximum connections pool size. The size of the pool to be maintained, defaults to 5. This is the largest number of connections that will be kept persistently in the pool. Note that the pool begins with no connections; once this number of connections is requested, that number of connections will remain.
max_overflow (int) – The maximum overflow size of the pool. When the number of checked-out connections reaches the size set in pool_size, additional connections will be returned up to this limit. When those additional connections are returned to the pool, they are disconnected and discarded. It follows then that the total number of simultaneous connections the pool will allow is pool_size + max_overflow, and the total number of “sleeping” connections the pool will allow is pool_size. max_overflow can be set to -1 to indicate no overflow limit; no limit will be placed on the total number of concurrent connections. Defaults to 10, will be used if value of the parameter in None.
pool_timeout (int) – The number of seconds to wait before giving up on returning a connection. Defaults to 30, will be used if value of the parameter is None.
5
None
None
Custom warnings.
Bases: Warning
Warn that an argument or call that was passed is not supported.
This subclasses Warning so that it can be filtered as a distinct category.
Bases: DeprecationWarning
Issued per usage of a deprecated API.
This subclasses DeprecationWarning so that it can be filtered as a distinct category.
Except where otherwise noted, this document is licensed under Creative Commons Attribution 3.0 License. See all OpenStack Legal Documents.