Skip to content

InfDB Class

Facade for configuration, logging, and DB connections for InfDB.

Other repos (e.g., infdb-import, infdb-basedata) should import and use this class as the single entry point.

__init__(tool_name: str, config_path: str = None, host: str = None) -> None

Initializes the facade with configuration and logging.

Parameters:

Name Type Description Default
tool_name str

Identifier used to pick the tool section in the config.

required
config_path str

Path to the YAML configuration file.

None
host str

The host address for the database connection.

None

__str__() -> str

Returns a string description of the InfDB facade.

get_logger() -> logging.Logger

Returns the root logger used by this instance.

get_worker_logger() -> logging.Logger

Creates and returns a worker logger from the InfdbLogger helper.

stop_logger() -> None

Stops the InfdbLogger's QueueListener.

connect() -> InfdbClient

Creates a new database client.

Prefer: with inf.connect(...) as client: ....

Args: None

Returns:

Type Description
InfdbClient

An InfdbClient connected to the requested database.

get_db_engine()

Returns a SQLAlchemy engine for the specified database.

Args: None

Returns:

Type Description

A SQLAlchemy Engine instance connected to the same target DB.

get_toolname() -> str

Returns the tool name configured for this instance.

get_config_dict() -> Dict[str, Any]

Returns the merged configuration dictionary.

get_db_parameters_dict() -> Dict[str, Any]

Returns final parameters dictionary for the postgres service.

get_config_value(keys: List[str], insert_toolname: bool = False)

Returns a value from the configuration by traversing a key path.

Parameters:

Name Type Description Default
keys List[str]

Ordered key path within the configuration.

required
insert_toolname bool

If True, prepend the tool name to the key path.

False

Returns:

Type Description

The value at the specified path, or None if missing.

get_config_path(keys: List[str], type: str = 'config', insert_toolname: bool = False) -> str

Resolves a filesystem path from config.

Parameters:

Name Type Description Default
keys List[str]

Ordered key path within the configuration.

required
insert_toolname bool

If True, prepend the tool name to the key path.

False

Returns:

Type Description
str

An absolute filesystem path.

get_env_variable(key) -> Optional[str]

Returns a dictionary of environment variables for this tool.

Returns:

Type Description
Optional[str]

A dictionary of environment variables.