Export the connection from one control hub and import to another control hub using sdk python script

Export script :  ( please ignore the api key and token being provided as hard coded value , this can be parameterized )


from streamsets.sdk import ControlHub
import json
API_TOKEN = "**"
connections = sch.connections.get_all()
for connection in connections:
    filename =' ', '_') + '.json'
    file= open(filename, "a")


With above code we are able to export the connection of pipeline from one control hub in Json file


Now to import the connection in another control hub . I am not sure if its feasible to do so? as we are not having enough information in json file. It carries only  (Connection id , name and type) . But it don't have Connection URL  and credential. Without that how can the connection be imported to another control hub ? Any suggestion please help . Also incase if I want to import the connection directly without bringing the details in json file then , is this right way?



connections = sch.connections.get_all()
for connection in onnections:
new_connection = t_sch.connections.add_connection(, connection.connection_type, connection.configuration)
print(f"Created new connection with ID {} on the target platform.")

0 replies

Be the first to reply!