globus1988
globus1988

Reputation: 75

Updating remote hyper file in Tableau Server

How can I update a remote hyper file by tableauhyperapi and tableauserverclient in Python? From what I have seen, it is possible to update a .hyper file that is saved locally.
So, I’ve tried to download a data source as a .hyper file using tableauserverclient to make the changes on it and then publish it and override the old one that is in Tableau Server.
The problem is that I can not download a data source as .hyper but only as .dtsx and from this file, I failed to extract the .hyper file.
Is there an elegant solution to this problem?

Upvotes: 1

Views: 1026

Answers (1)

Philip
Philip

Reputation: 51

This is how you can update the .hyper file on the Tableau server:

import tableauserverclient as TSC

tableau_auth =TSC.TableauAuth('yourUserName','yourPassword!','yourSiteName')
server = TSC.Server('yourServerURL',use_server_version=True)

with server.auth.sign_in(tableau_auth):
# Define publish mode - Overwrite, Append, or CreateNew
publish_mode = TSC.Server.PublishMode.Overwrite

# Get project_id from project_name
project_name = 'yourProjectName'
all_projects, pagination_item = server.projects.get()
#server access project below
for project in TSC.Pager(server.projects):
    print(project.id)
    print(project.name)
    if project.name == project_name:
        project_id = project.id

# Create the datasource object with the project_id
datasource = TSC.DatasourceItem(project_id)
# Publish datasource
datasource = server.datasources.publish(datasource, '.\output.hyper', publish_mode)
print("Datasource published. Datasource ID: {0}".format(datasource.id))

Here is the Tableau documentation: https://help.tableau.com/current/api/hyper_api/en-us/index.html Here are GitHub samples: https://github.com/tableau/hyper-api-samples

Upvotes: 1

Related Questions