반응형
Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
Tags
- Java
- google apps script
- Mac
- math
- PANDAS
- Python
- Tkinter
- Github
- Excel
- SQL
- hive
- Redshift
- numpy
- PySpark
- array
- GIT
- Google Excel
- gas
- Apache
- 파이썬
- dataframe
- matplotlib
- c#
- Google Spreadsheet
- string
- Kotlin
- django
- list
- PostgreSQL
Archives
- Today
- Total
달나라 노트
Python tableauserverclient : Refresh workbook 본문
Python/Python tableauserverclient
Python tableauserverclient : Refresh workbook
CosmosProject 2020. 12. 21. 16:28728x90
반응형
Tableau Server Client(TSC)
Let us check how to refresh workbook.
Filtering workbook using workbook name and refresh that workbook.
# --------------------------------------------------
# Chapter 3. Tableau workbbok refresh
# To refresh workbook you need workbook id of the workbook you want to refresh.
# To get workbook id, you can use filter function in Chapter 2
# --------------------------------------------------
import tableauserverclient as TSC
def TSC_filter_workbook():
tableau_server_url = 'tableau_url' # e.g. https://tableau-server.test.com
tableau_user_id = 'tableau_id'
tableau_user_pw = 'tableau_password'
server = TSC.Server(tableau_server_url)
tableau_auth = TSC.TableauAuth(tableau_user_id, tableau_user_pw)
print('Current REST API Version :', server.version)
server.version = '2.8' # Set version as 2.8
print('Modified Rest API Version :', server.version, '\n')
server.auth.sign_in(tableau_auth)
print('Logged in')
# In this example, I'm going to refresh workbook named 'A Dashboard'
# So I should get the workbook id of 'Quality Dashboard' using filter function.
req_options = TSC.RequestOptions()
req_options.filter.add(TSC.Filter(TSC.RequestOptions.Field.Name,
TSC.RequestOptions.Operator.Equals,
'A Dashboard'))
filter_items, pagination_items = server.workbooks.get(req_options)
workbook_info = filter_items[0]
workbook_name = workbook_info.name
workbook_id = workbook_info.id
print('Target workbook name :', workbook_name)
print('Target workbook id :', workbook_id, '\n')
# 'workbook_id' contains 'A Dashboard' workbooks's id.
# server.workbooks.get_by_id(workbook_id) means that give me 'workbook's information from 'server' with the 'workbook_id'
# And the workbook info will be put in 'workbook' variable.
# 'workbook.get_by_id' method is used when you have workbook id and you want to get the workbook's information.
workbook = server.workbooks.get_by_id(workbook_id)
server.workbooks.refresh(workbook) # 'workbook.refresh' method refreshes extracts of parameter(in this example refresh extracts of workbook in 'workbook' variable)
print('The workbook \'{}\' was refreshed.'.format(workbook_name), '\n')
server.auth.sign_out()
print('Logged out')
# Example Directory Structure
# Team_Apple (-> Project)
# ├── A Dashboard (-> Workbook)
# │ └── A Graph (-> View)
# ├── B Dashboard - PL (-> Workbook)
# │ └── B History (-> View)
# └── C (-> Workbook)
# ├── D_1 C (-> View)
# └── C History (-> View)
- Output
Current REST API Version : 2.3
Modified Rest API Version : 2.8
Logged in
Target workbook name : A Dashboard
Target workbook id : 95ad193f-g2ea-6132-b84d-b573523d0396
The workbook 'A Dashboard' was refreshed.
Logged out
728x90
반응형
'Python > Python tableauserverclient' 카테고리의 다른 글
Python tableauserverclient : populate (2) | 2022.05.25 |
---|---|
Python tableauserverclient : RequestOptions (Filtering) (0) | 2022.05.25 |
Python tableauserverclient : get (project class 얻기, workbook class 얻기, view class 얻기) (0) | 2022.05.25 |
Python tableauserverclient : Filtering (0) | 2020.12.21 |
Python tableauserverclient : Sign in & Sign out (0) | 2020.12.21 |
Comments