Sign up to take part
Registered users can ask their own questions, contribute to discussions, and be part of the Community!
Registered users can ask their own questions, contribute to discussions, and be part of the Community!
Hi Team,
Is there any way to extract the list of Dataiku projects with relevant snowflake connection used?
Thanks in Advance
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)
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.
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)