GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Tableau Document API Python
  • Docs
  • API Reference
  • Forum
  • Legal
  • Terms of Service
  • Privacy Information
  • Responsible Disclosure
  • Trust
  • Your Privacy Choices
  • GitHub page
  • All rights reserved.

This view

  • Original page
  • New address

GeezerVison is showing tableau.github.io — Get Started

  • Get Started
  • API Reference
  • Developer Guide
  • Contributing

Get Started

Edit this page   Submit an issue

To use this SDK, you must have Python 3 installed. The SDK is tested against Python 3.10 and later. (As of 2021, Python 2 is no longer supported.)

  • Installing the latest stable version (preferred)
  • Installing From Source
  • Installing the Development Version from Git
  • Basics
    • Samples

Installing the latest stable version (preferred)

pip install tableaudocumentapi

Installing From Source

Download the .zip file that contains the SDK. Unzip the file and then run the following command:

pip install -e <directory containing setup.py>

Installing the Development Version from Git

Only do this if you know you want the development version, no guarantee that we won’t break APIs during development

pip install git+https://github.com/tableau/document-api-python.git@development

If you go this route, but want to switch back to the non-development version, you need to run the following command before installing the stable version:

pip uninstall tableaudocumentapi

Basics

The following example shows the basic syntax for using the Document API to update a workbook:

from tableaudocumentapi import Workbook

sourceWB = Workbook('WorkbookToUpdate.twb')

sourceWB.datasources[0].connections[0].server = "MY-NEW-SERVER"
sourceWB.datasources[0].connections[0].dbname = "NEW-DATABASE"
sourceWB.datasources[0].connections[0].username = "benl"

sourceWB.save()

With Data Integration in Tableau 10, a data source can have multiple connections. To access the connections simply index them like you would datasources.

from tableaudocumentapi import Workbook

sourceWB = Workbook('WorkbookToUpdate.twb')

sourceWB.datasources[0].connections[0].server = "MY-NEW-SERVER"
sourceWB.datasources[0].connections[0].dbname = "NEW-DATABASE"
sourceWB.datasources[0].connections[0].username = "benl"

sourceWB.datasources[0].connections[1].server = "MY-NEW-SERVER"
sourceWB.datasources[0].connections[1].dbname = "NEW-DATABASE"
sourceWB.datasources[0].connections[1].username = "benl"


sourceWB.save()

Notes

  • Import the Workbook object from the tableaudocumentapi module.
  • To open a workbook, instantiate a Workbook object and pass the file name as the first argument.
  • The Workbook object exposes a list of datasources in the workbook
  • Each data source object exposes a connections list; each connection supports server, dbname, and username properties.
  • Save changes to the workbook by calling the save or save_as method.

Note: This call was added in version Tableau 10.3, XSDv2.5

Samples

The downloadable package contains several example scripts that show more detailed usage of the Document API.

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.