Tableau Prep Flow SDK - Programmatically generate .tfl files
Project description
cwprep - Tableau Prep Flow SDK
A Python SDK for programmatically generating Tableau Prep data flow (.tfl) files. Built through reverse-engineering the TFL JSON structure, enabling flow creation and modification via code without opening the GUI.
Installation
pip install cwprep
Quick Start
from cwprep import TFLBuilder, TFLPackager
# Create builder
builder = TFLBuilder(flow_name="My Flow")
# Add database connection
conn_id = builder.add_connection(
host="localhost",
username="root",
dbname="mydb"
)
# Add input tables
orders = builder.add_input_table("orders", "orders", conn_id)
customers = builder.add_input_table("customers", "customers", conn_id)
# Join tables
joined = builder.add_join(
name="Orders + Customers",
left_id=orders,
right_id=customers,
left_col="customer_id",
right_col="customer_id",
join_type="left"
)
# Add output
builder.add_output_server("Output", joined, "My_Datasource")
# Build and save
flow, display, meta = builder.build()
TFLPackager.save_to_folder("./output", flow, display, meta)
TFLPackager.pack_zip("./output", "./my_flow.tfl")
Features
| Feature | Method | Description |
|---|---|---|
| Database Connection | add_connection() |
Connect to MySQL/PostgreSQL/Oracle |
| SQL Input | add_input_sql() |
Custom SQL query input |
| Table Input | add_input_table() |
Direct table connection |
| Join | add_join() |
left/right/inner/full joins |
| Union | add_union() |
Merge multiple tables |
| Filter | add_filter() |
Expression-based filter |
| Value Filter | add_value_filter() |
Keep/exclude by values |
| Keep Only | add_keep_only() |
Select columns |
| Remove Columns | add_remove_columns() |
Drop columns |
| Rename | add_rename() |
Rename columns |
| Calculation | add_calculation() |
Tableau formula fields |
| Aggregate | add_aggregate() |
GROUP BY with SUM/AVG/COUNT |
| Pivot | add_pivot() |
Rows to columns |
| Unpivot | add_unpivot() |
Columns to rows |
| Output | add_output_server() |
Publish to Tableau Server |
Examples
See the examples/ directory for complete demos:
demo_basic.py- Input, Join, Outputdemo_cleaning.py- Filter, Calculate, Renamedemo_aggregation.py- Union, Aggregate, Pivotdemo_comprehensive.py- All features combined
Directory Structure
cwprep/
├── src/cwprep/ # SDK source code
│ ├── builder.py # TFLBuilder class
│ ├── packager.py # TFLPackager class
│ └── config.py # Configuration utilities
├── examples/ # Demo scripts
│ └── demo_data/ # Sample database SQL
├── docs/ # Documentation
└── tests/ # Unit tests
Configuration
Create config.yaml for default settings:
database:
host: localhost
username: root
dbname: mydb
port: "3306"
db_class: mysql
tableau_server:
url: http://your-server
project_name: Default
Changelog
See changelog.md for version history.
License
MIT License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cwprep-0.1.0.tar.gz.
File metadata
- Download URL: cwprep-0.1.0.tar.gz
- Upload date:
- Size: 12.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a9eecbe4e07895c8f968b8981a76f64449c85f0c8511e40078b646928092c7ac
|
|
| MD5 |
8b03b6bdcd6294a107e21f9aed507c5e
|
|
| BLAKE2b-256 |
eaaef24cca59137e6302736d58cfe73a4e57870c3de12dfaf134066a8c23d568
|
File details
Details for the file cwprep-0.1.0-py3-none-any.whl.
File metadata
- Download URL: cwprep-0.1.0-py3-none-any.whl
- Upload date:
- Size: 13.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f046daf61ead8af87bb9429c2ed04d7920cc20db47caa0597da41d722318e523
|
|
| MD5 |
27af6d15e701a764502c8a90b89d13f8
|
|
| BLAKE2b-256 |
a7cbe6ef411d0c4c3ec3af9b2768932355331469f5760c02f952094d8874296a
|