mafw.db.db_connection

Database connection configuration helpers.

Author:

Bulgheroni Antonio

Description:

Normalize database steering configuration into peewee connection arguments.

Module Attributes

VALID_AUTH_METHODS

Supported authentication methods for DBConfiguration.authentication.

LEGACY_KEYS

Keys reserved by the legacy DBConfiguration schema.

Functions

build_connection_parameters(config)

Normalize DBConfiguration mappings into peewee connection arguments.

mafw.db.db_connection.build_connection_parameters(config: Mapping[str, Any]) tuple[str, dict[str, Any]][source]

Normalize DBConfiguration mappings into peewee connection arguments.

The input can either be the full steering configuration dictionary or the nested DBConfiguration table. The returned tuple provides the URL and the keyword arguments for peewee.connect.

Parameters:

config (Mapping[str, Any]) – Steering configuration or DBConfiguration table.

Returns:

Tuple with database URL and connection keyword arguments.

Return type:

tuple[str, dict[str, Any]]

Raises:

ValueError – When required fields are missing or invalid.

mafw.db.db_connection.LEGACY_KEYS: set[str] = {'URL', 'pragmas'}

Keys reserved by the legacy DBConfiguration schema.

mafw.db.db_connection.VALID_AUTH_METHODS: set[str] = {'env', 'file', 'inline'}

Supported authentication methods for DBConfiguration.authentication.