Database schema name setting in dataset

Meirkhan
Meirkhan Registered Posts: 20 ✭✭✭✭

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

  • Vitaliy
    Vitaliy Dataiker, Dataiku DSS Core Designer, Dataiku DSS Adv Designer Posts: 102 Dataiker
    edited July 17 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

Setup Info
    Tags
      Help me…