I was hoping to solicit some feedback on the correct code syntax to Publish a Data Source with multiple connections and credentials (Oracle). I am using Python and the TSC package.
I have a data source with two Oracle connections using two different user name servers/credentials/passwords (Usernames/Schemas: TABLEAU_TECHNOLOGY and TABLEAU_PRODUCT).
The below code runs successfully however it sets the password for both User Names to the one tied to TABLEAU_TECHNOLOGY (Expected since that is the only one I am passing)
conn_cred = TSC.ConnectionCredentials(name='TABLEAU_TECHNOLOGY',password='123', embed=True, oauth=False)
all_projects, pagination_item = server.projects.get()
default_project = next((project for project in all_projects if project.is_default()), None)
migrated_ds = TSC.DatasourceItem(default_project.id)
server.datasources.publish(migrated_ds, 'C:/TSC_DS.tdsx', mode=TSC.Server.PublishMode.Overwrite, connection_credentials=conn_cred)
I then saw examples online of using a List object to append the Credentials for each User Name and pass that List Object. I have tried that in the below code:
conn_list = list()
conn_cred1 = TSC.ConnectionCredentials(name='TABLEAU_TECHNOLOGY', password='123', embed=True, oauth=False)
conn_cred2 = TSC.ConnectionCredentials(name='TABLEAU_PRODUCT', password='321', embed=True, oauth=False)
conn_list.append(conn_cred1)
conn_list.append(conn_cred2)
all_projects, pagination_item = server.projects.get()
default_project = next((project for project in all_projects if project.is_default()), None)
migrated_ds = TSC.DatasourceItem(default_project.id)
server.datasources.publish(migrated_ds, 'C:/TSC_DS.tdsx', mode=TSC.Server.PublishMode.Overwrite, connection_credentials=conn_list)
The error I receive with the above code snippet is:
credentials_element.attrib['name'] = connection_credentials.name
AttributeError: 'list' object has no attribute 'name'
My first thought is I somehow have to include the different Server Names in the connection information to ensure the correct credentials are applied. But as a first stab was just trying to apply the credentials to each source.
Has anyone successfully published a data source with two different servers/connections/credentials using TSC? If so would be great to understand what I may be missing. Please let me know if any other information is needed from the above 2 scenarios. I thank you in advance for any input