The goal is to allowed the capability to connect to more than one DB.
To keep the compatibility the main connection is connection by default with existing configuration. All Model use by default the main connection.
To define a named engine should be in configuration file:
[AnyBlok]
named_engine=pg2=>postgresql:///pg2,mysql=>mysql:///m1
To add a named engine in the model we give to way
@register(Model)
class MyModel:
__named_engine__ = 'pg2' # by default it is main
- In the configuration (keep the order)
[AnyBlok]
named_engine_for_Model.Test = mysql
named_engine_for_Model.Path.* = mysql
Add ignore_migration_for_named_engine as the other configuration
Add a fallback named_engine if engine not found in the configuration, by default None (raise an exception) for CI we can add
[Anyblok]
named_engine_fallback=main
or by env
ANYBLOK_NAMED_ENGINE_FALLBACK=main pytest
The goal is to allowed the capability to connect to more than one DB.
To keep the compatibility the main connection is connection by default with existing configuration. All Model use by default the main connection.
To define a named engine should be in configuration file:
To add a named engine in the model we give to way
Add ignore_migration_for_named_engine as the other configuration
Add a fallback named_engine if engine not found in the configuration, by default None (raise an exception) for CI we can add
or by env