Triggering Extract Refreshes with tableau_tools

If you have ETL processes that must run before your extracts can generate, it may make more sense to trigger an extract refresh (or the schedules) to run after the ETL has finished, rather than setting the extracts on a schedule. It maximizes your backgrounder processes by feeding their queues immediately when data is ready, and saves wasted effort if the ETL process fails.

As of Tableau Server version 10.0, there are no REST API commands to do this triggering, but tabcmd does have commands that can accomplish this. The tableau_tools Python library  has a Tabcmd class that wraps the most common tabcmd commands, including those for extract refreshes. Together with the tableau_rest_api sub-package, you can trigger off extract refreshes.

Note: Please use the latest version of tableau_tools (3.1.0+) to do the following.

Tabcmd class

The Tabcmd class is a wrapper around the tabcmd utility that comes with Tableau Server. You can also install tabcmd as a stand-alone utility in any directory on a machine (you can even install it on Linux!) To make everything work with the Tabcmd class, you’ll need to give some information about where tabcmd is installed on the machine.

logger = Logger(u'extract_refresh.log')

tabcmd_dir = "C:\\tabcmd\\Command Line Utility\\"
tabcmd_config_location = 'C:\\Users\\{}\\AppData\\Local\\Tableau\\Tabcmd\\'

server = ''
site_content_url = 'default'
username = '{}'
password = '{}'

tabcmd = Tabcmd(tabcmd_dir, server, username, password, site=site_content_url, tabcmd_config_location=tabcmd_config_location)



You’ll notice there is a ‘tabcmd_config_location’ area. tabcmd has a tabcmd-config.xml file which saves the session information. The Tabcmd class actually modifies this file and handles login dynamically on creation.

Triggering a Disabled Schedule to Run

One of the more interesting aspects of Tableau Server is that you can create an extract refresh schedule, but disable it. You can assign data source or a workbook to refresh on this schedule, but it will never run as long as it is disabled. You can still trigger off a disabled refresh schedule to run at any time with tabcmd. This makes a disabled schedule a convenient way to trigger everything you need to run all at once.


Triggering Individual Extract Refreshes

Tabcmd also has commands for refreshing extracts for individual Data Sources and Workbooks. Interestingly, if you attempt to trigger an extract refresh on a Live Connection, tabcmd just returns a simple error very quickly, without any implications. This means you can actually run through a list of all Data Sources or Workbooks and trigger all of their refreshes:

# Triggering all data sources to refresh
dses = t.query_datasources()
for ds in dses:
datasource_name = ds.get('name')
for element in ds.iter():
if element.tag.find('project') != -1:
project_name = element.get('name')

tabcmd.trigger_extract_refresh(project_name, 'datasource', datasource_name)

# Triggering all workbooks to refresh
wbs = t.query_workbooks()
for wb in wbs:
workbook_name = wb.get('name')
for element in wb.iter():
if element.tag.find('project') != -1:
project_name = element.get('name')

tabcmd.trigger_extract_refresh(project_name, 'workbook', workbook_name)

Assigning an Extract Refresh Schedule

There is also no REST API method as of 10.0 for putting an extract on a schedule (E-mail subscriptions, however, can be scheduled starting in 10.0). To fully automate the process of publishing a workbook and assigning a refresh schedule to it, you can do some work in the Tableau PostgreSQL Repository. It’s much more unsupported (full access to the Repository can be dangerous), but it works.






Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s