Bases: object
A helper class for removing of global engine instances from oslo.db.
Deprecated since version 1.12.0: Please use oslo_db.sqlalchemy.enginefacade for new development.
As a library, oslo.db can’t decide where to store/when to create engine and sessionmaker instances, so this must be left for a target application.
On the other hand, in order to simplify the adoption of oslo.db changes, we’ll provide a helper class, which creates engine and sessionmaker on its instantiation and provides get_engine()/get_session() methods that are compatible with corresponding utility functions that currently exist in target projects, e.g. in Nova.
engine/sessionmaker instances will still be global (and they are meant to be global), but they will be stored in the app context, rather that in the oslo.db context.
Two important things to remember:
Parameters: |
|
---|
Keyword arguments:
Parameters: |
|
---|
Initialize EngineFacade using oslo.config config instance options.
Parameters: |
|
---|
Get the engine instance (note, that it’s shared).
Parameters: | use_slave (bool) – if possible, use ‘slave’ database for this engine. If the connection string for the slave database wasn’t provided, ‘master’ engine will be returned. (defaults to False) |
---|
Get a Session instance.
Parameters: | use_slave (bool) – if possible, use ‘slave’ database connection for this session. If the connection string for the slave database wasn’t provided, a session bound to the ‘master’ engine will be returned. (defaults to False) |
---|
Keyword arguments will be passed to a sessionmaker instance as is (if passed, they will override the ones used when the sessionmaker instance was created). See SQLAlchemy Session docs for details.
Get the sessionmaker instance used to create a Session.
This can be called for those cases where the sessionmaker() is to be temporarily injected with some state such as a specific connection.
Apply configurational options to the global factory.
This method can only be called before any specific transaction-beginning methods have been called.
See also
_TransactionFactory.configure()
Return a LegacyEngineFacade for the global factory.
This facade will make use of the same engine and sessionmaker as this factory, however will not share the same transaction context; the legacy facade continues to work the old way of returning a new Session each time get_session() is called.
The global ‘reader’ starting point.
Construct a local transaction context.
Decorate a class with session and connection attributes.
The global ‘writer’ starting point.