Discover this year's submissions to the Dataiku Frontrunner Awards and give kudos to your favorite use cases and success stories!READ MORE

Connections mapped to the projects

Solved!
sj0071992
Neuron
Neuron
Connections mapped to the projects

Hi Team,

 

Is there any way to extract the list of Dataiku projects with relevant snowflake connection used?

 

Thanks in Advance

0 Kudos
1 Solution
sergeyd
Dataiker
Dataiker

Hi @sj0071992 

You should be able to retrieve this list with the next example (replace the <> placeholder): 

 

import dataiku

# client initialization:
client = dataiku.api_client()

# setting variables:
projects = client.list_project_keys()
connection_to_look = "<CONNECTION_NAME>"
project_list_using_connection = []

# going through the projects retrieving datasets:
for p in projects:
    proj = client.get_project(p)
    all_datasets = proj.list_datasets()

    # getting connection names from the datasets and comparing with the one we look:
    for dataset in all_datasets:
        try:
            connection = dataset["params"]["connection"]
            if dataset["params"]["connection"] == connection_to_look:
                # print("Project name", p, "contains connection", connection, "\n")
                project_list_using_connection.append(p)
                break
        except KeyError:
            pass  # skipping as dataset without connection

print("List of the projects using", connection_to_look, "connection:\n", project_list_using_connection)

 

 

 

 

View solution in original post

0 Kudos
4 Replies
sylvyr3
Level 3

I had a similar question but for me I was starting with a list of projects and retrieving all the connections.  You could probably generate a list of all project keys, iterate through them, and save the project key if it encounters the connection profile name you specify.

Script to list all connections used in a project 

0 Kudos
sergeyd
Dataiker
Dataiker

Hi @sj0071992 

You should be able to retrieve this list with the next example (replace the <> placeholder): 

 

import dataiku

# client initialization:
client = dataiku.api_client()

# setting variables:
projects = client.list_project_keys()
connection_to_look = "<CONNECTION_NAME>"
project_list_using_connection = []

# going through the projects retrieving datasets:
for p in projects:
    proj = client.get_project(p)
    all_datasets = proj.list_datasets()

    # getting connection names from the datasets and comparing with the one we look:
    for dataset in all_datasets:
        try:
            connection = dataset["params"]["connection"]
            if dataset["params"]["connection"] == connection_to_look:
                # print("Project name", p, "contains connection", connection, "\n")
                project_list_using_connection.append(p)
                break
        except KeyError:
            pass  # skipping as dataset without connection

print("List of the projects using", connection_to_look, "connection:\n", project_list_using_connection)

 

 

 

 

0 Kudos
Manuel
Dataiker
Dataiker

If you are an admin, you should also be able to see this in the UI. See attached image.

sj0071992
Neuron
Neuron
Author

Hi @sergeyd 

 

I Modified the code a little bit, but your solution worked.

Thanks for your help 😊