Database schema name setting in dataset
![Meirkhan](https://us.v-cdn.net/6038231/uploads/Dataiku/nAvatar8.png)
Hello!
I want to set database schema name programmatically for specific dataset.
P.S. I am aware that I can set default schema in global connection settings, but I need to do it for some specific datasets only
Best Answer
-
Hi @Meirkhan
,To update the schema of the dataset programmatically you can use Dataiku API. Please refer to the code snippet below (you can run it Python notebook):
import dataiku, json from dataiku import pandasutils as pdu import pandas as pd client = dataiku.api_client() proj_key = dataiku.default_project_key() project = client.get_project(proj_key) dataset = project.get_dataset('dataset_name') dataset_settings = dataset.get_settings() dataset_settings.settings["params"]["schema"] = 'new_schema' dataset_settings.save()
Hope this helps.
Best,
Vitaliy
Answers
-
Thanks!
I was trying to do get_settings() before, but it was not working.
Now I get why - I am using dss version 7. And one has to use get_definition() instead.
-
jvijayakumar2 Partner, Dataiku DSS Core Designer, Dataiku DSS Adv Designer, Registered Posts: 30 Partner
Do we have an R equivalent of this snippet?
-
Hi, there is no R equivalent available. However, if you want to stay within the R, you can use "reticulate" to execute python. Here is the full documentation of how you can use "reticulate": https://rstudio.github.io/reticulate/articles/calling_python.html
Best,
Vitaliy
-
jvijayakumar2 Partner, Dataiku DSS Core Designer, Dataiku DSS Adv Designer, Registered Posts: 30 Partner
Thanks @VitaliyD
!