Reputation: 305
I am very much new to the airflow and need to create environment variables start_date and end_date in airflow UI under admin tab in variables section using the code
Variable.set("start_date")
Variable.set("end_date")
and then retrieving the values of start_date and end_Date passed from airflow UI using
Variable.get("start_date")
Variable.get("end_date")
However not getting success because variables are not creating in airflow UI under admin tab in variables section using the code
Can anyone please help me ,how to create the variables using code and then retrieve the values
Upvotes: 0
Views: 1813
Reputation: 733
Airflow variables stores on the airflow database and it use the key, value structure to store and query variables. So if you want to set any variables on airflow do this on the UI:
Also, it's recommended to use JSON value if you use start_date and end_date for example on a specific dag because of it reduce querying from 2 times to 1 time like this:
Then you can use the variable like this:
variable = Variable.get("smaple")
start_date = variable['start_date']
end_date = variable['end_date']
Upvotes: 1