Tableau Server Client Python - Download Workbook _hot_
Often, you need to download all workbooks within a specific project. You can achieve this by iterating through the workbooks on your site and filtering by project name or ID.
To interact with your Tableau environment, you must first authenticate. You can use standard credentials (username and password) or the more secure .
with server.auth.sign_in(tableau_auth): # Use Pager to handle pagination automatically all_workbooks = TSC.Pager(server.workbooks) for workbook in all_workbooks: if workbook.project_name == 'Marketing': server.workbooks.download(workbook.id, filepath='./marketing_backups') print(f"Downloaded: {workbook.name}") Use code with caution. 5. Advanced Options API reference - Tableau - GitHub tableau server client python download workbook
To download a workbook, you need its unique (ID). The server.workbooks.download method handles the request and saves the file locally.
Automating the process of downloading workbooks from Tableau Server or Tableau Cloud can save significant time for administrators and developers. The library for Python provides a streamlined way to interact with the Tableau REST API to perform these tasks programmatically. 1. Prerequisites and Installation Often, you need to download all workbooks within
with server.auth.sign_in(tableau_auth): # Specify the workbook ID workbook_id = 'your-workbook-luid-here' # Download the workbook # The method returns the file path of the downloaded .twbx or .twb file file_path = server.workbooks.download(workbook_id, filepath='./downloads') print(f"Workbook downloaded to: {file_path}") Use code with caution. 4. Bulk Download Workbooks by Project
Before you start, ensure you have Python installed on your system. You can install the TSC library using pip: pip install tableauserverclient Use code with caution. 2. Authentication You can use standard credentials (username and password)
import tableauserverclient as TSC # Using Personal Access Token tableau_auth = TSC.PersonalAccessTokenAuth('TOKEN_NAME', 'TOKEN_VALUE', 'SITENAME') server = TSC.Server('https://your-server-url.com', use_server_version=True) Use code with caution. 3. Downloading a Single Workbook