dlt.config accessor provides dictionary-like access to configuration values. Use it to access non-sensitive configuration values like API endpoints, batch sizes, or feature flags.
Basic Usage
Methods
__getitem__(field: str)
Get a configuration value by field name. Raises ConfigFieldMissingException if not found.
Configuration key to retrieve. Use dot notation for nested values (e.g.,
"sources.github.api_url").get(field: str, expected_type: Type = None)
Get a configuration value with optional type casting. Returns None if not found.
Configuration key to retrieve.
Expected type to deserialize the value into (e.g.,
int, bool, list).expected_type, or None if not found.
Example:
__setitem__(field: str, value: Any)
Set a configuration value programmatically.
Configuration key to set. Use dot notation for sections.
Value to store.
__contains__(field: str)
Check if a configuration value exists.
Example:
Automatic Injection with dlt.config.value
Use dlt.config.value as a default argument value to automatically inject configuration:
sources.<source_name>.<resource_name>.<arg_name>sources.<source_name>.<arg_name><arg_name>
Configuration Sources
Thedlt.config accessor reads from multiple providers in order:
- Environment variables (e.g.,
SOURCES__GITHUB__API_URL) config.tomlfile in.dlt/directorysecrets.tomlfile (config can also be stored here)- Airflow Variables (when running in Airflow)
- Google Secret Manager, AWS Secrets Manager, etc. (if configured)
dlt.secrets instead.
Configuration File Example
In.dlt/config.toml:
Environment Variables
Configuration can be provided via environment variables using double underscores for nesting:See Also
- dlt.secrets - For accessing sensitive configuration values
- Configuration documentation - Detailed guide on configuration