DEV Community 👩‍💻👨‍💻

Jakub T
Jakub T

Posted on

Accessing Tableau with Python

You can find the Tableau SDK Python docs: https://tableau.github.io/server-client-python/docs/

In order to be able to refresh the Datasources you need to get their ids:

import tableauserverclient as TSC


USERNAME = ''
PASSWORD = ''
SITE_ID  = ''


tableau_auth = TSC.TableauAuth(USERNAME, PASSWORD, site_id=SITE_ID)
server = TSC.Server('https://dub01.online.tableau.com')
server.auth.sign_in(tableau_auth)

datasources, _ = server.datasources.get()

tags_to_refresh = {'production'}

# We want to refresh only the datasources with the production tag

datasource_ids = [datasource.id for datasource in datasources if (datasource.tags & tags_to_refresh)]

for datasource_id in datasource_ids:
    item = server.datasources.get_by_id(datasource_id)
    result = server.datasources.refresh(item)
    print(result)

Top comments (1)

Collapse
 
aza profile image
Aza

Thank you!

DEV

Thank you.

 
Thanks for visiting DEV, we’ve worked really hard to cultivate this great community and would love to have you join us. If you’d like to create an account, you can sign up here.