Skip to content

Added pool of named engine #171

Description

@jssuzanne

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

  • In the blok
@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

Activity

  1. added this to the 1.1.0 milestone on Feb 27, 2021
  2. modified the milestones: 1.1.0, 1.2.0 on Mar 22, 2021
  3. modified the milestones: 1.2.0, 1.3.0 on Apr 14, 2021
  4. modified the milestones: 1.3.0, 1.3.1 on Jul 11, 2021
  5. modified the milestones: 1.4.0, 2.0.0, 2.1.0 on Feb 18, 2023
  6. modified the milestones: 2.1.0, 2.2.0 on Jul 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions