Contents
Registry
plugin¶anyblok_multi_engines.registry.
MixinSession
Bases: object
Mixin for the SQLAlchemy session the goal is to allow the connection with more than one engine: masters / slaves engines
get_bind
(mapper=None, clause=None)Overload the Session.get_bind
method of SQLAlchemy
the rule are:
anyblok_multi_engines.registry.
MultiEngines
Bases: object
Mixin class which overload the AnyBlok Registry class
the goal is to implement in the the Registry the masters / slaves behaviour
bind
Return the bind in function of engine
close
()Overwrite close to cloe all the engines
create_session_factory
()Overwrite the creation of Session factory to Use the multi binding
engine
Return the engine
get_engine_for
(ro=True)Return one engine among the engines
Parameters: | ro – if True the engine will be read only else write only |
---|---|
Return type: | engine |
Exception: | RegistryException |
init_bind
()Initialise the bind for unittest
init_engine
(db_name=None)Overload the initiation of engine to create more than one engine
use the Configuration option to create engines:
Warning
All the engines use the same database name not at the same location
Parameters: | db_name – name of the database for the engines |
---|
anyblok_multi_engines.registry.
RegistryMultiEngines
(db_name, loadwithoutmigration=False, unittest=False, **kwargs)Bases: anyblok_multi_engines.registry.MultiEngines
, anyblok.registry.Registry
Pluging class
get_url
plugin¶anyblok_multi_engines.config.
get_url
(db_name=None, url=None)¶Return an sqlalchemy URL for database
Parameters: |
|
---|---|
Return type: | SqlAlchemy URL |
Exception: | ConfigurationException |