Skip to content

graflo.db.connection.config_mapping

get_config_class(db_type)

Get the appropriate config class for a database type.

This factory function breaks the circular dependency by moving the lookup logic out of the DBType enum.

Parameters:

Name Type Description Default
db_type DBType

The database type enum value

required

Returns:

Type Description
Type[DBConfig]

The corresponding DBConfig subclass

Raises:

Type Description
KeyError

If the db_type is not in the mapping

Source code in graflo/db/connection/config_mapping.py
def get_config_class(db_type: DBType) -> Type[DBConfig]:
    """Get the appropriate config class for a database type.

    This factory function breaks the circular dependency by moving the
    lookup logic out of the DBType enum.

    Args:
        db_type: The database type enum value

    Returns:
        The corresponding DBConfig subclass

    Raises:
        KeyError: If the db_type is not in the mapping
    """
    return DB_TYPE_MAPPING[db_type]