Script for modifiying the HDFS connection paths

SAURABH
SAURABH Partner, Dataiku DSS Core Designer, Dataiku DSS ML Practitioner, Dataiku DSS Core Concepts, Dataiku DSS Adv Designer, Registered Posts: 26 Partner
edited July 16 in Using Dataiku

Hi Team,

I have created a script to modify the connection details specificaly the HDFS "path", but facing an error which says
script :

import dataiku
import prettyprinter
client = dataiku.api_client()
client._session.verify=False
dss_connections = client.list_connections()
#prettyprinter.pprint(dss_connections)
for connection in dss_connections:
name=connection['Testing']
dss_connections = client.get_connection(name)
con_defination=dss_connections.get_definition()
connection_definition['root'] = Abc
dss_connections.set_definition(con_definition)
con_defination_modified=dss_connections.get_definition()
pprint.pprint(con_defination_modified)

Error :

TypeError                                 Traceback (most recent call last
      5 for connection in dss_connections:
----> 6     name=connection['Testing']
      7     #dss_connections = client.get_connection(name)
      8     #con_defination=dss_connections.get_definition()

TypeError: string indices must be integers

can some one please assist i need to modify 100 of connection at the same time

Answers

  • Turribeach
    Turribeach Dataiku DSS Core Designer, Neuron, Dataiku DSS Adv Designer, Registered, Neuron 2023 Posts: 2,032 Neuron
    edited July 17

    Please always post your code using the Code block. This should do what you want:

    client = dataiku.api_client()
    all_connections = client.list_connections()
    for connection in all_connections:
        connection_handle = client.get_connection(connection)
        connection_definition = connection_handle.get_definition()
        if connection == 'some_connection_name':
            connection_definition['params']['root'] = '/test/worked'
            connection_handle.set_definition(connection_definition)
Setup Info
    Tags
      Help me…