Skip to content

Interface and Operations / Environment Variables

When users want their code to run by reading configurations, instead of directly embedding the configuration within the code, a better approach is to use the "Environment Variables" feature provided by DataFlux Func.

Using environment variables can prevent sensitive configuration information from being exported along with scripts during export

List of Environment Variables

Select the "Environment Variables" tab in the left sidebar to display all added environment variables.

Adding an Environment Variable

When you need to add a new environment variable, select "Add Environment Variable" in the left sidebar, enter the value of the environment variable, and specify its type.

The Environment Variable ID is the unique identifier used to reference this environment variable in scripts.

Using Environment Variables

Once environment variables are properly added, they can be accessed in scripts using the environment variable ID to get the corresponding value.

Additionally, the system will automatically convert the specified "value type" into the corresponding Python object, so no additional type conversion handling is required in the code.

Assuming there exists an ID my_config, the code to retrieve the value of this environment variable would be as follows:

Python
1
my_config = DFF.ENV('my_config')

You can also directly copy basic example code from the environment variable hint box, reducing keyboard input:


Quote

For details on how to use environment variables in scripts, refer to the documentation Script Development / Environment Variables DFF.ENV