# Path: oslo_db/exception.py
# class DBError(CausedByException):
# class DBDuplicateEntry(DBError):
# class DBConstraintError(DBError):
# class DBReferenceError(DBError):
# class DBNonExistentConstraint(DBError):
# class DBNonExistentTable(DBError):
# class DBNonExistentDatabase(DBError):
# class DBDeadlock(DBError):
# class DBInvalidUnicodeParameter(Exception):
# class DBMigrationError(DBError):
# class DBConnectionError(DBError):
# class DBDataError(DBError):
# class DBNotSupportedError(DBError):
# class InvalidSortKey(Exception):
# class ColumnError(Exception):
# class BackendNotAvailable(Exception):
# class RetryRequest(Exception):
# class NoEngineContextEstablished(AttributeError):
# class ContextNotRequestedError(AttributeError):
# class CantStartEngineError(Exception):
#     def __init__(self, inner_exception=None, cause=None):
#     def __init__(self, columns=None, inner_exception=None, value=None):
#     def __init__(self, table, check_name, inner_exception=None):
#     def __init__(self, table, constraint, key, key_table,
#                  inner_exception=None):
#     def __init__(self, table, constraint, inner_exception=None):
#     def __init__(self, table, inner_exception=None):
#     def __init__(self, database, inner_exception=None):
#     def __init__(self, inner_exception=None):
#     def __init__(self):
#     def __init__(self, message):
#     def __init__(self, key=None):
#     def __init__(self, inner_exc):
# 
# Path: oslo_db/options.py
# def set_defaults(conf, connection=None, max_pool_size=None,
#                  max_overflow=None, pool_timeout=None):
# def list_opts():
# 
# Path: oslo_db/sqlalchemy/engines.py
# LOG = logging.getLogger(__name__)
# def _thread_yield(dbapi_con, con_record):
# def _connect_ping_listener(connection, branch):
# def _setup_logging(connection_debug=0):
# def _extend_url_parameters(url, connection_parameters):
# def _vet_url(url):
# def create_engine(sql_connection, sqlite_fk=False, mysql_sql_mode=None,
#                   mysql_enable_ndb=False,
#                   connection_recycle_time=3600,
#                   connection_debug=0, max_pool_size=None, max_overflow=None,
#                   pool_timeout=None, sqlite_synchronous=True,
#                   connection_trace=False, max_retries=10, retry_interval=10,
#                   thread_checkin=True, logging_name=None,
#                   json_serializer=None,
#                   json_deserializer=None, connection_parameters=None):
# def _init_connection_args(
#     url, engine_args,
#     max_pool_size=None, max_overflow=None, pool_timeout=None, **kw):
# def _init_connection_args(url, engine_args, **kw):
# def _init_connection_args(url, engine_args, **kw):
# def _init_connection_args(url, engine_args, **kw):
# def _init_connection_args(url, engine_args, **kw):
# def _init_connection_args(url, engine_args, **kw):
# def _init_events(engine, thread_checkin=True, connection_trace=False, **kw):
# def _init_events(engine, mysql_sql_mode=None, **kw):
#         def _set_session_sql_mode(dbapi_con, connection_rec):
#     def _check_effective_sql_mode(dbapi_con, connection_rec):
# def _init_events(engine, sqlite_synchronous=True, sqlite_fk=False, **kw):
#     def regexp(expr, item):
#     def _sqlite_connect_events(dbapi_con, con_record):
#     def _sqlite_emit_begin(conn):
#     def _sqlite_end_transaction(conn):
# def _test_connection(engine, max_retries, retry_interval):
# def _add_process_guards(engine):
#     def connect(dbapi_connection, connection_record):
#     def checkout(dbapi_connection, connection_record, connection_proxy):
# def _add_trace_comments(engine):
#     def before_cursor_execute(conn, cursor, statement, parameters, context,
#                               executemany):
# 
# Path: oslo_db/sqlalchemy/orm.py
# class Query(sqlalchemy.orm.query.Query):
# class Session(sqlalchemy.orm.session.Session):
#     def soft_delete(self, synchronize_session='evaluate'):
#     def update_returning_pk(self, values, surrogate_key):
#     def update_on_match(self, specimen, surrogate_key, values, **kw):
# def get_maker(engine, autocommit=True, expire_on_commit=False):
# 
# Path: oslo_db/warning.py
# class NotSupportedWarning(Warning):
# class OsloDBDeprecationWarning(DeprecationWarning):


import contextlib
import functools
import inspect
import operator
import threading
import warnings
import debtcollector.moves
import debtcollector.removals
import debtcollector.renames
from oslo_config import cfg
from oslo_utils import excutils
from oslo_db import exception
from oslo_db import options
from oslo_db.sqlalchemy import engines
from oslo_db.sqlalchemy import orm
from oslo_db import warning
                "_TransactionContextManager or "
                "_TransactionFactory expected.")
        if self._root is not self:
            raise AssertionError('patch_factory only works for root factory.')
        existing_factory = self._root_factory
        self._root_factory = factory

        def reset():
            self._root_factory = existing_factory

        return reset

    def patch_engine(self, engine):
        """Patch an Engine into this manager.

        Replaces this manager's factory with a _TestTransactionFactory
        that will use the given Engine, and returns
        a callable that will reset the factory back to what we
        started with.

        Only works for root factories.  Is intended for test suites
        that need to patch in alternate database configurations.

        """

        existing_factory = self._factory
        if not existing_factory._started:
            existing_factory._start()
        maker = existing_factory._writer_maker
        maker_kwargs = existing_factory._maker_args_for_conf(cfg.CONF)

# Path: oslo_db/exception.py
# class DBError(CausedByException):
# class DBDuplicateEntry(DBError):
# class DBConstraintError(DBError):
# class DBReferenceError(DBError):
# class DBNonExistentConstraint(DBError):
# class DBNonExistentTable(DBError):
# class DBNonExistentDatabase(DBError):
# class DBDeadlock(DBError):
# class DBInvalidUnicodeParameter(Exception):
# class DBMigrationError(DBError):
# class DBConnectionError(DBError):
# class DBDataError(DBError):
# class DBNotSupportedError(DBError):
# class InvalidSortKey(Exception):
# class ColumnError(Exception):
# class BackendNotAvailable(Exception):
# class RetryRequest(Exception):
# class NoEngineContextEstablished(AttributeError):
# class ContextNotRequestedError(AttributeError):
# class CantStartEngineError(Exception):
#     def __init__(self, inner_exception=None, cause=None):
#     def __init__(self, columns=None, inner_exception=None, value=None):
#     def __init__(self, table, check_name, inner_exception=None):
#     def __init__(self, table, constraint, key, key_table,
#                  inner_exception=None):
#     def __init__(self, table, constraint, inner_exception=None):
#     def __init__(self, table, inner_exception=None):
#     def __init__(self, database, inner_exception=None):
#     def __init__(self, inner_exception=None):
#     def __init__(self):
#     def __init__(self, message):
#     def __init__(self, key=None):
#     def __init__(self, inner_exc):
# 
# Path: oslo_db/options.py
# def set_defaults(conf, connection=None, max_pool_size=None,
#                  max_overflow=None, pool_timeout=None):
# def list_opts():
# 
# Path: oslo_db/sqlalchemy/engines.py
# LOG = logging.getLogger(__name__)
# def _thread_yield(dbapi_con, con_record):
# def _connect_ping_listener(connection, branch):
# def _setup_logging(connection_debug=0):
# def _extend_url_parameters(url, connection_parameters):
# def _vet_url(url):
# def create_engine(sql_connection, sqlite_fk=False, mysql_sql_mode=None,
#                   mysql_enable_ndb=False,
#                   connection_recycle_time=3600,
#                   connection_debug=0, max_pool_size=None, max_overflow=None,
#                   pool_timeout=None, sqlite_synchronous=True,
#                   connection_trace=False, max_retries=10, retry_interval=10,
#                   thread_checkin=True, logging_name=None,
#                   json_serializer=None,
#                   json_deserializer=None, connection_parameters=None):
# def _init_connection_args(
#     url, engine_args,
#     max_pool_size=None, max_overflow=None, pool_timeout=None, **kw):
# def _init_connection_args(url, engine_args, **kw):
# def _init_connection_args(url, engine_args, **kw):
# def _init_connection_args(url, engine_args, **kw):
# def _init_connection_args(url, engine_args, **kw):
# def _init_connection_args(url, engine_args, **kw):
# def _init_events(engine, thread_checkin=True, connection_trace=False, **kw):
# def _init_events(engine, mysql_sql_mode=None, **kw):
#         def _set_session_sql_mode(dbapi_con, connection_rec):
#     def _check_effective_sql_mode(dbapi_con, connection_rec):
# def _init_events(engine, sqlite_synchronous=True, sqlite_fk=False, **kw):
#     def regexp(expr, item):
#     def _sqlite_connect_events(dbapi_con, con_record):
#     def _sqlite_emit_begin(conn):
#     def _sqlite_end_transaction(conn):
# def _test_connection(engine, max_retries, retry_interval):
# def _add_process_guards(engine):
#     def connect(dbapi_connection, connection_record):
#     def checkout(dbapi_connection, connection_record, connection_proxy):
# def _add_trace_comments(engine):
#     def before_cursor_execute(conn, cursor, statement, parameters, context,
#                               executemany):
# 
# Path: oslo_db/sqlalchemy/orm.py
# class Query(sqlalchemy.orm.query.Query):
# class Session(sqlalchemy.orm.session.Session):
#     def soft_delete(self, synchronize_session='evaluate'):
#     def update_returning_pk(self, values, surrogate_key):
#     def update_on_match(self, specimen, surrogate_key, values, **kw):
# def get_maker(engine, autocommit=True, expire_on_commit=False):
# 
# Path: oslo_db/warning.py
# class NotSupportedWarning(Warning):
# class OsloDBDeprecationWarning(DeprecationWarning):


# Path: oslo_db/sqlalchemy/enginefacade.py
import contextlib
import functools
import inspect
import operator
import threading
import warnings
import debtcollector.moves
import debtcollector.removals
import debtcollector.renames
from oslo_config import cfg
from oslo_utils import excutils
from oslo_db import exception
from oslo_db import options
from oslo_db.sqlalchemy import engines
from oslo_db.sqlalchemy import orm
from oslo_db import warning

                "_TransactionContextManager or "
                "_TransactionFactory expected.")
        if self._root is not self:
            raise AssertionError('patch_factory only works for root factory.')
        existing_factory = self._root_factory
        self._root_factory = factory

        def reset():
            self._root_factory = existing_factory

        return reset

    def patch_engine(self, engine):
        """Patch an Engine into this manager.

        Replaces this manager's factory with a _TestTransactionFactory
        that will use the given Engine, and returns
        a callable that will reset the factory back to what we
        started with.

        Only works for root factories.  Is intended for test suites
        that need to patch in alternate database configurations.

        """

        existing_factory = self._factory
        if not existing_factory._started:
            existing_factory._start()
        maker = existing_factory._writer_maker
        maker_kwargs = existing_factory._maker_args_for_conf(cfg.CONF)

        maker = orm.get_maker(engine=engine, **maker_kwargs)