db_facts package

Submodules

db_facts.base64_jinja_context module

db_facts.base64_jinja_context.pull_base64_jinja_context(db_name, dbcli_config)

Returns a Jinja context that exports the following functions:

  • b64decode(s: str) -> str: Converts a base64ed string to its original contents.

  • b64encode(s: str) -> str: Converts a string to its base64ed form.

Return type

Tuple[Dict[str, Any], Dict[str, Callable[[Any], Any]]]

db_facts.env_jinja_context module

db_facts.env_jinja_context.pull_env_jinja_context(db_name, dbcli_config)

Returns a Jinja context that exports the following functions:

  • getenv(key: str, default: Optional[str]=None) -> Optional[str]: Return the value of the environment variable key if it exists, or default if it doesn’t. key, default and the result are str.

  • env(key: str) -> str: Looks up an environment variable value, or raises KeyError if not found.

Return type

Dict[str, Any]

Module contents

db_facts.DBFacts

The central part of internal API.

This represents a generic version of type ‘origin’ with type arguments ‘params’. There are two kind of these aliases: user defined and special. The special ones are wrappers around builtin collections and ABCs in collections.abc. These must have ‘name’ always set. If ‘inst’ is False, then the alias can’t be instantiated, this is used by e.g. typing.List and typing.Dict.

alias of Dict[str, Any]

exception db_facts.UserErrorException

Bases: Exception

Raised upon an error related to the inputs to the db() function.

db_facts.db(db_name, dbcli_config=None)

Get connection info for specified database.

Parameters

db_name (List[str]) – Alias for the particular database endpoint and account to connect to. [‘a’,’b’,’c’] corresponds to ‘a-b-c’ on the db-facts command-line.

Raises

UserErrorException – Raised if db_name cannot be found.

Return type

Dict[str, Any]