Script for modifiying the HDFS connection paths

saurabh
Level 3
Script for modifiying the HDFS connection paths

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 

0 Kudos
1 Reply
Turribeach

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)
0 Kudos