Sign up to take part
Registered users can ask their own questions, contribute to discussions, and be part of the Community!
Registered users can ask their own questions, contribute to discussions, and be part of the Community!
I want to perform changes in the code of my SQL recipes in a project. How can I access the code?
import dataiku
import dataikuapi
client = dataiku.api_client()
project = client.get_project("project")
recipes = project.list_recipes()
for recipe in recipes:
recipe_code = recipe.get_code() # can't figure out this step
alter_code(recipe_code)โ
Hi @imanousar,
For SQL recipe you need to use get_payload() and set_payload() instead of get_code(), which only works for R/Python/Bash recipes and not SQL.
client = dataiku.api_client()
current_project = client.get_project(dataiku.default_project_key())
current_recipe = current_project.get_recipe("compute_outnow")
recipe_settings = current_recipe.get_settings()
code = recipe_settings.get_payload()
final_code = 'SELECT abc,edf FROM "TESTING_2_postgres_out"'
recipe_settings.set_payload(final_code)
recipe_settings.save()
Hi @imanousar,
For SQL recipe you need to use get_payload() and set_payload() instead of get_code(), which only works for R/Python/Bash recipes and not SQL.
client = dataiku.api_client()
current_project = client.get_project(dataiku.default_project_key())
current_recipe = current_project.get_recipe("compute_outnow")
recipe_settings = current_recipe.get_settings()
code = recipe_settings.get_payload()
final_code = 'SELECT abc,edf FROM "TESTING_2_postgres_out"'
recipe_settings.set_payload(final_code)
recipe_settings.save()