Join us on July 16th as we explore real-world Reinforcement Learning Learn more

Macro to Query Database and Return List or Dict of Tables to Global Variables

Level 3
Macro to Query Database and Return List or Dict of Tables to Global Variables

So apparently I can't read a dataset in a Python plugin unless I declare it as an input?  Weird because I can with my do() function in my resource folder. 

Now I'm going to try and run a macro in the plugin to update a global variable. I will then read that global variable in to my plugin script.  

I need to return a list of strings of all table names from my SQL database into the project variable/global variables.  How can I do this with a macro?  

1 Reply
Dataiker
Dataiker

Hi,

Although it is not recommended,  you can read a dataset in a plugin recipe even if it's not declared as input.

For that, instead of dataset = dataiku.Dataset("myname"), use dataset = dataiku.Dataset("myname", ignore_flow=True)

To list SQL tables in a database, please see this method on the DSSProject class: https://doc.dataiku.com/dss/latest/python-api/rest-api-client/projects.html#dataikuapi.dss.project.D...