8000 Merge pull request #1 from mpope-tableau/master · Lakkichand/document-api-python@1ae3195 · GitHub
[go: up one dir, main page]

Skip to content

Commit 1ae3195

Browse files
committed
Merge pull request tableau#1 from mpope-tableau/master
Update README.md merging this and Mike is going to add ```python formatting to code
2 parents 31aca0e + c4c7d04 commit 1ae3195

File tree

1 file changed

+44
-13
lines changed

1 file changed

+44
-13
lines changed

README.md

Lines changed: 44 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,54 @@
11
# tableausdk-python
22

3-
Tableau SDK for Python. Currently this contains only the Document API. We are just getting started and this will evolve. Help us by submitting feedback, issues, and pull requests!
3+
This repo contains Python source and example files for the Tableau SDK. Currently the repo contains only the Document API. We're just getting started and have plans to expand what you find here. Help us by submitting feedback, issues, and pull requests!
44

55
Document API
66
---------------
7-
This is the supported way to programmatically change Tableau files such as .twb and .tds. If you've been doing "XML hacking" this is for you too :)
8-
9-
Check out the examples to see how to use it.
7+
The Document API provides a supported way to programmatically make updates to Tableau workbook (`.twb`) and data source (`.tds`) files. If you've been making changes to these file types by directly updating the XML--that is, by XML hacking--this SDK is for you :)
108

119
Currently only the following operations are supported:
1210

13-
* Modify database server
14-
* Modify database name
15-
* Modify database user
11+
- Modify database server
12+
- Modify database name
13+
- Modify database user
14+
15+
We don't yet support creating files from scratch. In addition, support for `.twbx` and `.tdsx` files is coming.
16+
17+
18+
###Getting Started
19+
To use this SDK, you must have Python installed. You can use either 2.7x or 3.3x.
20+
21+
Download the `.zip` file that contains the SDK. Unzip the file and then run the following command:
22+
23+
pip install -e <directory containing setup.py>
24+
25+
We plan on putting the package in PyPi to make installation easier.
26+
27+
28+
###Basics
29+
The following example shows the basic syntax for using the Document API to update a workbook:
30+
31+
from tableaudocumentapi import Workbook
32+
33+
sourceWB = Workbook('WorkbookToUpdate.twb')
34+
35+
sourceWB.datasources[0].connection.server = "MY-NEW-SERVER"
36+
sourceWB.datasources[0].connection.dbname = "NEW-DATABASE"
37+
sourceWB.datasources[0].connection.username = "benl"
38+
39+
sourceWB.save()
40+
41+
42+
**Notes**
43+
44+
- Import the `Workbook` object from the `tableaudocumentapi` module.
45+
- To open a workbook, instantiate a `Workbook` object and pass the `.twb` file name in the constructor.
46+
- The `Workbook` object exposes a `datasources` collection.
47+
- Each datasource object has a `connection` object that supports a `server`, `dbname`, and `username` property.
48+
- Save changes to the workbook by calling the `save` or `save_as` method.
49+
50+
1651

17-
We don't yet support creating files from scratch. Support for .twbx and .tdsx is coming.
52+
###Examples
1853

19-
##### Getting Started
20-
We will put this in PyPi to make installation easier. In the meantime, install the package locally with:
21-
```python
22-
pip install -e <directory containing setup.py>
23-
```
54+
The downloadable package contains an example named `replicateWorkbook.py` (in the folder `\Document API\Examples\Replicate Workbook`). This example reads an existing workbook and reads a .csv file that contains a list of servers, database names, and users. For each new user in the .csv file, the code copies the original workbook, updates the `server`, `dbname`, and `username` properties, and saves the workbook under a new name.

0 commit comments

Comments
 (0)
0