Author name: cndro

Blogs

How to Get Tableau Server User Details and Data Sources

How to get Tableau server user details and datasources. Tableau Server is a product from Tableau that allows you to use the functionality of Tableau without having to download and open workbooks in Tableau desktop.  It works like every other server that lets you store things safely and also provides a collaborative environment for working. Tableau users publish data sources to the server when they want to share data connections they’ve defined. It is important to know how to get Tableau Server user details and data sources from tons of data sources. Tableau Server Client(TSC) is a Python library for the Tableau Server REST API. You can read about TSC here. There are instances where a lot of Tableau server users; let’s say thousands publish a huge number of data sources. You will agree that it will look disorganized when you don’t know who published a particular data source or which data source a user published.  It is important to know that on the server, there is always a unique identifier(id) for each data source. Also, there is an owner identifier (owner_id) of the data source. The owner identifier(owner_id) indicates the user that publishes on the server which also corresponds to the user identifier(user_id).  I assume you have Python 3 installed if not you can download anaconda which comes with Python packages. In this tutorial, you will learn how to get Tableau server user details and data sources using Tableau Server Client. Let’s get in. Step 1: Connect to the Tableau Server using the Tableau Server Client(TSC) library. Input these lines of code which includes the username and password to login to the server. import tableauserverclient as TSC import pandas as pd tableau_auth = TSC.TableauAuth(‘Username’, ‘Password’) This line of code includes the connection link to the server and login. server = TSC.Server(‘http://3.227.165.186’) request_options = TSC.RequestOptions(pagesize=1000) with server.auth.sign_in(tableau_auth): Step 2: Get the list of all the users. Input this line of code to fetch the list of all the users on the Tableau server. Then input the user id and the user name of the Tableau server in a dictionary, a key value pair. all_users = list(TSC.Pager(server.users, request_options)) userinfo = [{user.id:user.name} for user in all_users] Step 3: Get the list of all the data sources. Now, we will get the list of all the data sources and all the unique data source identifiers on the Tableau server. Input these lines of code all_datasources = list(TSC.Pager(server.datasources, request_options)) datasource_ids = [datasource.id for datasource in all_datasources] Step 4: Use Pandas library to get the user id, the user name, the data source id, and the data source owner id in a data frame. Placing the user information into a Pandas Data Frame is a good way to interact with the list and perform other operations. (a)Input the code below as a template for getting user details into a Pandas Data Frame and sign out afterward. datasource_owner_id = [{datasource.name:datasource.owner_id} for datasource in all_datasources] print(‘The datasource name and the consecutive datasource owner_id for the default site is as follows:’,datasource_owner_id) server.auth.sign_out() The next part of the code will get the user id and the name of the server users. It will then turn it to columns of a data frame. Now, we can open a list for key1, key22, value1, and value22. Then append the dictionary values and keys to the list. Append key2 to key22 empty list and value2 to the value22 empty list for userdiction in userinfo: for key2, value2 in userdiction.items(): key22.append(key2) value22.append(value2) df = pd.DataFrame({“datasource_owner_id”:key22,”Name”:value22}) (b) Make a loop to go through the dictionary in the data source_owner_id. Get the key and the value of the Dictionary “data”  and append the key to the key1 empty list. Then, append the value to the value1 empty list. key1 = [] value1 = [] for data in data source_ owner_id: for key, value in data.items(): key1.append(key) value1.append(value) df2 = pd.DataFrame({“datasource_name”:key1,”datasource_owner_id”:value1}) Note that at this point there are two different data frames. The first one is the df and the other is the df2. The df contains the list of all ids of the users of the server and the name of all the users of the server.     Step 5: Map the users of the server to all the data sources that they published. The next line of code joins the two data frames and merges the two data sets with the datasource_owner_id column. result = pd.merge(df, df2[[‘datasource_name’,’datasource_owner_id’]], on=’datasource_owner_id’) Step 6: Finally, save the data frame to a CSV file. print(result) result.to_csv The result of the joined table will look like the image below.  If you found this blog post helpful, kindly share it on social platforms with the buttons below. Questions are welcomed in the comments section.

Blogs

VPC Peering in Amazon Web Services (AWS)

Amazon Virtual Private Cloud, shortly known as Amazon VC or simply VPC, is a virtual network dedicated to your AWS account, that enables you to launch AWS resources to a virtual network you defined. It is the networking layer of your Amazon EC2. In this article, I will be sharing a walkthrough on how to carry out VPC peering in Amazon Web Services (AWS). A VPC peering connection is a one to one relationship between two VPCs. It is a networking connection between two VPCs that allows you to route traffic between them privately. You can create a peering connection between two of your VPCs, or with a VPC of another AWS account. For this article we will be peering an RDS database and an Amazon workspace, each having different VPCs. Here is what you’ll need: 1)A running RDS database on AWS. I am using Microsoft SQL. 2) Amazon workspace. STEPS 1. Log in to AWS console (https://console.aws.amazon.com/console/home) 2. Select “RDS” from the Database menu to launch it. 3. Select the database you want to peer with the AWS workspace by clicking on it. 4. From the page displayed afterward, Copy the VPC security group to your clipboard. We now have the VPC of the RDS database. The next thing to do is to get the VPC of the Amazon workspace. 5. Search for “workspace” using the search tab on your console’s interface. 6. Select the AWS workspace whose VPC you want to peer. You can reach out to your AWS admin to get the VPC of the Workspace. The next thing to do is to carry out the VPC peering in AWS. Search for VPC and click on it. 7. Click on Your VPC, as indicated by the yellow arrow in the image above, to see the VPCs running on your AWS console.   8. to establish peering, click on Peering Connections as indicated by the green arrow in the image above. 9. Select “Create Peering” and fill in the parameters as shown in the image below:   Peering Connection name (indicated with the blue arrow): Put your desire peering name/tag VPC (Requester) (indicated with the orange arrow):  Input the VPC of the AWS cloud service that wants to connect to another. In this scenario, the VPC of the RDS database. Select another VPC to peer with (indicated with the green arrow): Select the account and region where the other VPC is. In this scenario, we will choose “My account” and “This region”. This is because the two AWS services (RDS and workspace) were created with my account and are in the same region. Choose the second option if otherwise. VPC (Accepter) (indicated with the yellow arrow): The VPC of the AWS cloud service that wants to accept the connection. In this scenario, the VPC of the AWS workspace. 10. Select “Create Peering Connection” to establish a VPC peering connection. After the peering connection has been established, you should something like the picture below: VPC peering in Amazon Web Services has quite a few limitations and restrictions. You can check them out here.

Scroll to Top