Connections mapped to the projects

sj0071992
sj0071992 Partner, Dataiku DSS Core Designer, Neuron, Dataiku DSS Adv Designer, Registered, Dataiku DSS Developer, Neuron 2022, Neuron 2023 Posts: 131 Neuron

Hi Team,

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

Thanks in Advance

Best Answer

  • Sergey
    Sergey Dataiker, Dataiku DSS Core Designer, Dataiku DSS & SQL, Dataiku DSS Core Concepts Posts: 365 Dataiker
    edited July 17 Answer ✓

    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)

Answers

  • sylvyr3
    sylvyr3 Registered Posts: 21 ✭✭✭✭

    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.

  • Manuel
    Manuel Alpha Tester, Dataiker Alumni, Dataiku DSS Core Designer, Dataiku DSS ML Practitioner, Dataiku DSS Core Concepts, Dataiku DSS Adv Designer, Registered Posts: 193 ✭✭✭✭✭✭✭

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

  • sj0071992
    sj0071992 Partner, Dataiku DSS Core Designer, Neuron, Dataiku DSS Adv Designer, Registered, Dataiku DSS Developer, Neuron 2022, Neuron 2023 Posts: 131 Neuron

    Hi @sergeyd

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

    Thanks for your help

Setup Info
    Tags
      Help me…