gibz104 / tableau-datasource-refresher

Selenium browser to automate Tableau Public data sources.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

tableau-datasource-refresher

This python code uses a headless Selenium browser to request a data refresh on a Tableau Public dashboard.

Tests Coverage Py Versions Test OS

Background

Tableau Public allows you to create and publish dashboards for free that can be accessed by anyone online. There is no authetication (or cost) for the number of users that view your dashboard, nor the resources to host and maintain the dashboard. The catch is that Tableau Public only allows you to connect to a very limited subset of data sources and they cannot be setup to be refreshed on a schedule.

However, there is a button on the Tableau Public UI that allows you to manually trigger a refresh for the data source the workbook is connected to. The purpose of this repository was to create a program that uses a headless Selenium browser to login as the owner of a dashboard and click this UI button that will trigger a data source refresh. The idea is you can schedule this program to run on a set schedule (say every hour) to trigger a refresh to the dashboard without requiring any orchestration/scheduling on the Tableau Public side.

Usage

Instantiate the TableauPublic class

  • username parameter should be the username of the dashboard owner

  • password parameter should be the password of the dashboard owner

tableau = TableauPublic(
    username='username',
    password='password',
    headless=True,
)

Next call the refresh_datasource method by passing the url endpoint of the dashboard you want refreshed. When this method is called, Selenium will log you into Tableau Public with the provided username/password and then refresh the dashboard's data source.

tableau.refresh_datasource('/app/profile/user/viz/dashboardname')

Tests

Basic unittests are in place in the /tests directory which can be run locally using pytest. There is also a github workflow associated with this repo that will run the tests and report the code coverage on every push (https://github.com/gibz104/tableau-datasource-refresher/actions/workflows/tests.yaml).

Tests have been run on python versions 3.8, 3.9, and 3.10 on Ubuntu, Mac OS, and Windows. Testing status and coverage are reported as badges at the top of this readme.

Disclaimer

Run this code at your own risk.

About

Selenium browser to automate Tableau Public data sources.


Languages

Language:Python 100.0%