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

Solved!
gblack686
Level 4
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 Solution
Clรฉment_Stenac

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...

View solution in original post

1 Reply
Clรฉment_Stenac

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...