mafw.db

Defines the DB interface and its public custom field types.

class mafw.db.StorageField(checksum_field: str | None = None, *args: Any, **kwargs: Any)[source]

Bases: TextField

Store a physical path or logical reference in one self-describing text field.

Ordinary physical paths retain their legacy untagged representation. Paths beginning with the reserved mafw: prefix are written with a mafw:path: envelope. Logical references use mafw:logical:<volume>:<relative/path>. Incomplete or malformed reserved-looking values remain legacy physical paths; a complete unknown codec identifier raises ValueError.

A string assigned in Python is always treated as a physical path. Assign a LogicalFileReference object for logical data. The codec never resolves paths or accesses a storage service.

Automatic checksum propagation occurs only for physical values. For a logical value, provide a resolved physical path or an already computed checksum explicitly.

Parameters:

checksum_field – Optional name of the associated checksum field.

Added in version 2.4.

Initialize a text field with an optional physical checksum association.

accessor_class

alias of StorageFieldAccessor

db_value(value: str | Path | LogicalFileReference | None) → str | None[source]

Serialize one physical or logical storage value.

python_value(value: str | None) → Path | LogicalFileReference | None[source]

Decode storage text into a physical path or logical reference.

class mafw.db.StorageListField(checksum_field: str | None = None, *args: Any, **kwargs: Any)[source]

Bases: StorageField

Store an ordered, self-describing list of physical and logical values.

Values use the existing semicolon-separated text format. A physical list member containing ; is rejected because it cannot be represented unambiguously. Existing text is decoded using the historical split rule. SQL NULL and empty text both produce an empty list.

Parameters:

checksum_field – Optional name of the associated checksum field.

Added in version 2.4.

Initialize a text field with an optional physical checksum association.

db_value(value: Iterable[str | Path | LogicalFileReference] | str | Path | LogicalFileReference | None) → str | None[source]

Serialize list members in order without escaping legacy delimiters.

python_value(value: str | None) → list[Path | LogicalFileReference][source]

Decode a semicolon-separated list, preserving order and duplicates.

Modules

db_configurations

Module provides default configurations for different database engines.

db_connection

Database connection configuration helpers.

db_filter

Database filter module for MAFW.

db_model

The module provides functionality to MAFw to interface to a DB.

db_types

Database Type Definitions

db_wizard

The module allows to generate a DB model structure starting from an existing DB.

fields

Module provides customised model fields specific for MAFw.

migration

Versioned database schema migration package.

model_register

Module for registering and retrieving database models.

reflection

Reflect database schemas into Python model modules.

std_tables

Module provides standard tables that are included in all database created by MAFw processor.

trigger

Module provides a Trigger class and related tools to create triggers in the database via the ORM.