We're excited to announce that we're launching the second installment of Dataiku Product Days Register Now

Database schema name setting in dataset

Solved!
Meirkhan
Level 3
Database schema name setting in dataset

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

0 Kudos
1 Solution
VitaliyD
Dataiker
Dataiker

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

View solution in original post

0 Kudos
2 Replies
VitaliyD
Dataiker
Dataiker

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

View solution in original post

0 Kudos
Meirkhan
Level 3
Author

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.

 

 

0 Kudos
A banner prompting to get Dataiku DSS