SDK Configuration

This information will help you understand what configuration files are available in DBND and how to update them.

DBND SDK uses its own configuration system that enables you to set and update your configuration in the most usable way. In consists of:

  • Configuration files
  • Environment Variables
  • Code
  • External Configs (for example: Airflow Connection)

Environment Variables

You can set any system parameter by using environment variables.
For example, you can override the databand_url parameter under the core section by setting a value for the DBND__CORE__DATABAND_URL environment variables.
Similarly, you can construct environment variables for other configuration parameters by using DBND__<SECTION>__<KEY> format.

Configuration files in DBND

DBND loads configuration information sequentially from the following configuration files:

File loading priority

File Location

File Description

1

$DBND_LIB/databand-core.cfg

Provides the default core configuration of the system that cannot be changed.

2

$DBND_SYSTEM/databand-system.cfg

Provides middle layer configuration. We suggest to use this file for project infrastructure configuration

3

$DBND_HOME/project.cfg

Provides a project configuration. Should be used for configuring "user" facing parts of the project.

4

$USER_HOME/.dbnd/databand.cfg

Provides system user configuration.

5

Custom location

You can also create additional configuration files by using DBND__CONF__FILE environment variable.

πŸ‘

Note

Configuration information available in files specified in lower configuration layers overrides the configuration specified in the top layers.

For example, you have config key A specified in the $DBND_SYSTEM/databand-system.cfg. If in $DBND_HOME/project.cfg the configuration of A is specified, then DBND uses the configuration specified in the lower configuration layer, i.e. $DBND_HOME/project.cfg.
See ConfigParser.read.

Environment variables in Configuration files

You can use $DBND_HOME, $DBND _LIB or $DBND_SYSTEM in your configuration file, or any other environment variable:

How to change the configuration for a specific section of the code:

You can use the config context manager to set up the configuration in code:

from dbnd import config
with config({"section": {"key": "value"}}):
    YOUR_CODE()

You can also load configuration from a file:

from dbnd._core.configuration.config_readers import read_from_config_file
with config(read_from_config_file("/path/to/config.cfg")):
    YOUR_CODE()
### Q: How do I pass list parameter in .cfg file?
A: The syntax is as follows:
```ini
[some_section]
list_param = [1, 2, 3, "str1"]

Q: How do I pass dictionary parameter in .cfg file?

A: The syntax is as follows:

[some_section]
dict_param = {"key1": "value1", 255: 3}

Q: Is it possible to have multiple configuration files? For instance, if there are different use cases or some default variables are overridden in prod or test.

A: Yes, to specify extra file, you can set an environment variable:
export DBND_CONFIG=<extra_file_path>

Q: Can I use multiple extra config files?

A: Yes, -- conf and DBND__DATABAND__CONF variables support multiple files (as a list of files separated by comma).

Q: How to control the output type of dbnd_config?

A: The dbnd_config is a β€˜dict’-like object that only stores the mapping to value. To control the output type of dbnd_config.get ("section", "key"), you can use getboolean , getint, or getfloat (for permeative types).


What’s Next
Did this page help you?