SYS username mapped to Snowflake Connection

sj0071992
SYS username mapped to Snowflake Connection

Hi Team,

I am looking for an API which will help me to extract the Connection Details of all Dataiku projects and the username mapped to it.

 

Basically i am looking for Snowflake connection and SYS username mapped to it in all the Dataiku projects.

Is it possible to extract these details?

 

Thanks in Advance

0 Kudos
3 Replies
AlexT
Dataiker

Hi,

You can list all connections from all projects if that is what you are looking for using :

 

import dataiku
import pandas as pd, numpy as np
import pprint

pp = pprint.PrettyPrinter(indent=4)

connections = client.list_connections()
#pp.pprint(dss_connections)

for connection in connections:
    connections[connection] = client.get_connection(connection)
    connection_definition = connections[connection].get_definition()
    try:
        if connection_definition['type'] == 'Snowflake' and connection_definition['params']['user'] == 'SYS':
            print(connection_definition)
    except  Exception as e: print(e)

 

 

This would list all the connections details where it's snowflake and username SYS.

You can then print out the name of the connection and use the functionality found under :

Administration - Monitoring - Per-connection data to find out their usage in a project. 

Please note you will need Admin privileges to list all connections. 

0 Kudos
sj0071992
Author

Hi Alex,

 

This is perfect.

 

Can we also add warehouse details in the same code?

which warehouse is mapped to that connection.

 

Thanks in advance

0 Kudos
AlexT
Dataiker

Yes, you can simply use :

 

connection_definition['params']['warehouse'] that will be the value of the warehouse you can filter of print as seen in the sample code. 

Let me know if you have any issues.

0 Kudos