Registered users can ask their own questions, contribute to discussions, and be part of the Community!
I need to build a python script that retrieves for every recipe (SQL) in a given project (project name = 'RANDOM') its content as a string.
I will put the output (recipe as a string) in a dictionary, with the recipe name as a key.
Do you have any Dataiku specific functions that gets the recipe query, or do you have ideas to be able to iterate over all recipes and store the recipe content?
Thanks for the support!
Operating system used: Windows
The following code should get you started:
client = dataiku.api_client()
project_obj = client.get_project('SOMEPROJKEY')
recipe_types = ('sql_script', 'sql_query')
for recipe_specs in project_obj.list_recipes():
if recipe_specs['type'] in recipe_types:
recipe_obj = project_obj.get_recipe(recipe_specs['name'])
recipe_settings_obj = recipe_obj.get_settings()
recipe_payload = recipe_settings_obj.str_payload
Note that I extracted the following code snippet from a search and replace process and haven't run it after doing that so possible that there are some typos or something.
Also, this will only work for projects you have access to. To access other projects you'd need to get the client using an API key .
Post a Question