Environment¤
Environment-based configuration loading.
See Also¤
- Config Overview - All config tools
- Loaders - Config file loaders
- CLI - Command-line configuration
- Core Config - Config protocol
datarax.config.environment ¤
Environment variable integration for configuration.
This module provides utilities for integrating environment variables with configuration files, allowing for environment-specific overrides.
get_env_value ¤
Get a value from an environment variable.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
env_var
|
str
|
The name of the environment variable (without prefix) |
required |
default
|
Any
|
Default value to return if the environment variable is not set |
None
|
prefix
|
str
|
Prefix to apply to the environment variable name |
'DATARAX_'
|
Returns:
| Type | Description |
|---|---|
str | None
|
The environment variable value, or the default if not set |
apply_environment_overrides ¤
apply_environment_overrides(config: dict[str, Any], prefix: str = 'DATARAX_', separator: str = '__') -> dict[str, Any]
Apply environment variable overrides to a configuration dictionary.
Environment variables can override configuration values using a naming
convention. For example, to override config.database.host, the environment
variable would be DATARAX_DATABASE__HOST.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
dict[str, Any]
|
The configuration dictionary to apply overrides to |
required |
prefix
|
str
|
Prefix for environment variables to consider |
'DATARAX_'
|
separator
|
str
|
Separator used to indicate nested keys |
'__'
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Configuration dictionary with environment overrides applied |