I use a Python script get a datetime in Snowflake then i convert it in a format to be able to put this variable when i call the API ( so it becomes dynamic and i dont need to change it manually). Here is a part of my script:
from datetime import datetime
#Get last_import datetime
cursor = context.cursor() cursor.execute('SELECT MAX("datetime") FROM "AGP_DWH"."PUBLIC"."REPORT_STATUS_SUMMARY_TEST_DWH"') result = cursor.fetchone() last_import = result.strftime("%Y-%m-%dT%H:%M:%S") context.updateVariable('starting_date', 'last_import') print last_import print starting_date
And there are the result of the print: 2019-06-07T19:00:00 last_import
How can i update the value of my starting_date environnement variable with the value of last_import so i'll get 2019-06-07T19:00:00 store and not last_import ...
3 Community Answers
Arawan Gajajiva —
Hi Maxim -
I believe you should not have the last_import variable wrapped in single quotes in the context.updateVariable line of your code. By wrapping it in single quotes, it’s being treated as a string and not as a reference to your variable.
As such, I think you need to update this line from: