Tableau Server Client (TSC) - CNDRO.LLC
1855
post-template-default,single,single-post,postid-1855,single-format-standard,wp-custom-logo,theme-bridge,bridge-core-2.9.4,woocommerce-no-js,tribe-no-js,ehf-template-bridge,ehf-stylesheet-bridge-child,qode-page-transition-enabled,ajax_fade,page_not_loaded,,qode-title-hidden,qode_grid_1300,footer_responsive_adv,hide_top_bar_on_mobile_header,columns-4,qode-child-theme-ver-1.0.0,qode-theme-ver-27.8,qode-theme-bridge,qode_header_in_grid,wpb-js-composer js-comp-ver-6.7.0,vc_responsive,elementor-default,elementor-kit-2634

Tableau Server Client (TSC)

There are different methods used in communicating with the Tableau Server, but one of the outstanding methods is through the Tableau Server Client (TSC). The tableau server is one of the tools in the tableau software product suite. You can read about tableau and it’s tools here. In this article, I am going to share with you what TSC is and how important it is to any Tableau developer

What is TSC?

Tableau Server Client (TSC) is a python library for the Tableau Server REST API. You can do almost everything on the Tableau Server with the REST API. You can create users, create groups, query projects, query sites to retrieve data sources and workbooks, you can do so much more on the Tableau Server just with the Tableau Server Client. One of the strengths of this python library (TSC), is that you can query multiple data sources and workbooks at a time.
TSC allows you to communicate with the tableau server using python programming language, giving you more control over the server.

Downloading datasources from Tableau server using TSC.

Downloading data sources is an inevitable task for every tableau developer. Since this task is a very common one, I am going to show you how to carry it out effectively using TSC. I’m going to do a quick walkthrough of how to download all the datasources that has been published to the Tableau server default site. For this purpose of this article, I’m going to use the Jupyter notebook. You can also use your favorite IDE to carry out this process.

This process is the same for all versions of the tableau server, but I used version 10.5.3. So, let’s jump right in:

Step 1: Launch Jupyter notebook. Install TSC using the python line below:

 !pip install tableauserverclient

Step 2: Once the library has been installed, authenticate the connection to the TSC so that Tableau server can identify you as a user.

 tableau_auth = TSC.TableauAuth('USERNAME', 'PASSWORD', 'SITENAME')

In your case, input your username and password in the respective fields, and “default” as the sitename, because we are trying to download datasources from the default site. If it was from a different site, you will input the name of the site instead.

Step 3: After the authentication stage, declare your server to establish a connection between TSC and the server. This can be done with this line of code:

 server = TSC.Server('Your Tableau Server Public IP')

Step 4: Get all the datasources in the default site using this line of code:

with server.auth.sign_in(tableau_auth):
    all_datasources, pagination_item = server.datasources.get()

Step 5: Get all the IDs of the datasources so you can use it in referencing the operations that you want to perform on the site. The code for this step is:

    datasource_ids = [datasource.id for datasource in all_datasources] 

Step 6: Print the total number of datasources in the default site. Then, print the number of the datasources to be downloaded from the server 10.5.3

  print("\nThere are {} datasources on site ".format(len(all_datasources))) 
  print("\nThere are {} datasources to be downloaded on site:  ".format(pagination_item.total_available))

Step 7: Loop through the datasources using their ids and download the datasources to your local machine.

    for id in datasource_ids: 
        if file_download.lower().endswith('.tdsx'): 
        file_download = server.datasources.download(id)
        print(file_download)  

Step 9: Finally, sign out of the server so your information on it is saved.

server.auth.sign_out() 

Your Jupyter notebook should look like this image below:

 

How to download datasources from the tableau server default site.

Importance of Tableau Server Client to a Tableau Developer

As a Tableau developer, having full understanding and control of the Tableau server is of extreme importance. Tableau Server administration is a required skill in the 21st century as a Tableau Developer. TSC helps you to administer your tableau server easily. It makes you able to send instructions to your server from your local computer, publish datasources and workbooks to the server from your local machine.

No Comments

Post A Comment