Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/memiiso/pytableau
pytableau, schedule tableau resports
https://github.com/memiiso/pytableau
datasources pdf reporting scheduling-reports tableau workbooks
Last synced: about 1 month ago
JSON representation
pytableau, schedule tableau resports
- Host: GitHub
- URL: https://github.com/memiiso/pytableau
- Owner: memiiso
- License: gpl-3.0
- Created: 2020-01-16T19:26:36.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2023-10-04T00:57:17.000Z (about 1 year ago)
- Last Synced: 2024-04-21T19:05:23.316Z (8 months ago)
- Topics: datasources, pdf, reporting, scheduling-reports, tableau, workbooks
- Language: Python
- Homepage:
- Size: 48.8 KB
- Stars: 7
- Watchers: 2
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
![Python package](https://github.com/memiiso/pytableau/workflows/Python%20package/badge.svg)
Distribute Tableu reports using workbook tags. Using any of csv, pdf, pgn export formats
Interact with Tableu server, Download tableu content, triger datasource/extract refresh task# Installation
```
pip install https://github.com/memiiso/pytableau/archive/master.zip --upgrade --user
```# PyTableau
Python wrapper for tableau server api.
Tableau class to interact with tableau server and server content- download_all_datasources
- download_all_workbooks
- export_all_datasource_fields_to_csv
- export_all_workbook_fields_to_csv
- download_workbook_pdf
- download_workbook_png
- download_workbook_csv
- refresh_extracts# PyTableauReportScheduler
tableau class to emailing reports as pdf using workbook tagsforexample a workbook with following tags
- sent to user1, user2 every day,
- sent to user3 Weekly on Mondays,
- sent to user4, user2 at the first day of month every month.```
'scheduledReport'
,'Daily:to:user1@mail.com','Daily:cc:user2@mail.com'
,'Weekly1:to:user3@mail.com'
,'Monthly1:to:user4@mail.com','Monthly1:cc:user2@mail.com'
```a workbook with following tags sent
- Weekly every Wednesday
- monthly every 16th day of month```
'scheduledReport'
,'Weekly3:to:user3@mail.com'
,'Monthly16:to:user4@mail.com','Monthly1:cc:user2@mail.com'
```#### Schedule tags
Daily = send every dayWeekly* = * is weekday number(1...7) sends the report at given weekday
Monthly* = * is month day number(1...31) sends the report at given month day
## PyTableau Examples
#### Init
```python
import os
import smtplib
from pathlib import Path
from pytableau import PyTableau, PyTableauReportScheduler
from urllib.parse import quote_plusmyTableau = PyTableau(server_address='http_tableau_server',
username='mytableauuser@mail.com',
password='mypassword',
site_id='Default'
)
```## Refreshing Datasources
```python
datasource_list = ['my Datasource1', 'my Datasource2', "Datasource3"]
myTableau.refresh_extracts(datasource_names=datasource_list, synchronous=True)
```## Downloading All Server Workbooks, Datasources
```python
download_dir = "/tmp/test_download_all_datasources"
Path(download_dir).mkdir(parents=True, exist_ok=True)
myTableau.download_all_workbooks(download_dir)
```## Querying Server Workbooks, Datasources
```python
tag='dailyKpi'
wbs = myTableau.get_workbooks_by_tag(tag=tag)
print("Found %s Workbook with tag:%s" % (str(len(wbs)), tag))
wb = myTableau.get_workbook_by_name(name='XYZ KPI REPORT', project_name='FINANCETEAM', tag='XYZKPI')
print(wb.name)
print(wb.updated_at)
wb = myTableau.get_workbook_by_name(name='XYZ REPORT', project_name='XYZ TEAM')
print(wb.name)
```## Exporting Workbook to PDF
```python
# find the workbook
wb = myTableau.get_workbook_by_name(name='XYZ DASHBOARD', project_name='PROJECT_NAME')
# export it to PDF
myTableau.download_workbook_pdf(workbook=wb, dest_dir="/tmp/somedir/")
```## PyTableauReportScheduler Examples
#### Init
```python
import os
import smtplib
from pathlib import Path
from pytableau import PyTableau, PyTableauReportScheduler
from urllib.parse import quote_plusmyTableau = PyTableau(server_address='http_tableau_server',
username='mytableauuser@mail.com',
password='mypassword',
site_id='Default'
)mysmtp = smtplib.SMTP_SSL('smtp.gmail.com', 465)
mysmtp.ehlo()
mysmtp.login('myemail@mail.com', 'mypassword')# email all the reports with tag : scheduledReport
myTabScheduler= PyTableauReportScheduler(tableau=myTableau,smtp_server=mysmtp,schedule_tag="scheduledReport")
```## Emailing Reports
```python
datafilters = dict()
datafilters["Report Year"]="2019,2020"
datafilters["Country"]="US"
# send reports daily, weekly, monthly.
myTabScheduler.send_scheduled_reports(send_from='senderemail@mail.com', data_filters=datafilters)# send weekly Monday reports.
myTabScheduler.send_schedule(send_from='senderemail@mail.com', schedule='Wekkly1',data_filters=datafilters)
```