sqltrack.config module¶
This module contains functions to locate and parse SQLTrack config files.
- sqltrack.config.find_config_file(path: Path | str | None = None, config_name='sqltrack.conf')[source]¶
If either
pathargument orSQLTRACK_CONFIG_PATHenvironment variable is notNone. Thepathargument takes precedence if both are defined.Otherwise, if no explicit path is given, these default location are checked, in this order:
./sqltrack.conf$XDG_CONFIG_HOME/sqltrack/sqltrack.conf%APPDATA%/sqltrack/sqltrack.conf$HOME/.config/sqltrack/sqltrack.conf$HOME/sqltrack.conf
The first path that exists is returned, or
Noneif none can be found.
- sqltrack.config.get_env_config() dict[source]¶
Load config from environment variables. Variables names need to match
SQLTRACK_DSN_<PARAM>, where<PARAM>is converted to lowercase in the returned dictionary.
- sqltrack.config.load_config(path: Path | str | None = None, config_name='sqltrack.conf', **kwargs) dict[source]¶
Locates and parses config files, as well as other sources which can add or override parameters.
find_config_file()with the givenpathargument is used to determine which config file to load.ValueErroris raised if an explicitly specified config file (by either thepathargument or theSQLTRACK_CONFIG_PATHenvironment variable) does not exist.The final config is assembled as follows, starting with the the default config:
DEFAULT_CONFIG = { "engine": "postgres", "dbpath": "sqltrack.db", "user": getpass.getuser(), "dbname": getpass.getuser(), }
Parameters are added or overridden in this order:
Parsed from config file, if any.
From
SQLTRACK_DSN_<PARAM>environment variables. (seeget_env_config()for details).kwargsgiven to this function.