Reputation: 384
I would like to fetch only those datasources
which are of type: Extract, and skip on the Live Data Sources. I am using tableauserverclient
python library.
I have found code online to filter on the basis of data source name but I want to filter on the basis of data source type. Below is the code to filer on data source name:
req_option = TSC.RequestOptions()
req_option.filter.add(TSC.Filter(TSC.RequestOptions.Field.Name,
TSC.RequestOptions.Operator.Equals,
'Superstore'))
datasources = server.datasources.get(req_option)
Upvotes: 0
Views: 631
Reputation: 1444
According to the docs, there is no way to filter on source type in the req_options. These are the items you can filter on in req_options:
For the above endpoints, you can filter or sort on the following fields:
CreatedAt
LastLogin
Name
OwnerName
SiteRole
Tags
UpdatedAt
There is a has_extracts
attribute you can use after you pull all data sources though.
Try this code:
with server.auth.sign_in(tableau_auth):
# get all projects on site
all_project_items, pagination_item = server.datasources.get()
for x in all_project_items:
if x.has_extracts:
print(x.name, x.id, x.project_name, x.has_extracts)
Upvotes: 1