Skip to content

graflo.connections.mapping

Attributes

DB_TYPE_MAPPING = {DBType.ARANGO: ArangoConfig, DBType.NEO4J: Neo4jConfig, DBType.TIGERGRAPH: TigergraphConfig, DBType.FALKORDB: FalkordbConfig, DBType.MEMGRAPH: MemgraphConfig, DBType.NEBULA: NebulaConfig, DBType.POSTGRES: PostgresConfig, DBType.SPARQL: SparqlEndpointConfig, DBType.GRAFLO_BACKEND: GraFloBackendConfig} module-attribute

Classes

Functions:

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/connections/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]