pytd
Treasure Data Driver for Python
What it is and what it does
pytd is a Python driver for Treasure Data that bridges pandas DataFrames with Treasure Data's query engines and storage. It wraps the REST API, Presto query engine, and Plazma primary storage into a single client interface, letting you issue SQL queries and retrieve results as structured data, or write DataFrames back to Treasure Data using bulk import or INSERT INTO methods.
The package is designed for analytical workflows in Jupyter notebooks and Python applications where you need to move data between pandas and Treasure Data efficiently. It supports both Presto and Hive query engines, offers generator-based iterative result retrieval via DB-API to handle timeouts on large result sets, and provides multiple data ingestion strategies—bulk import for scalability, INSERT INTO for memory efficiency on smaller datasets, or Spark for high-performance writes to Plazma storage (requires special account activation).
Use it for:
- Run Presto or Hive SQL queries against Treasure Data and retrieve results as Python dicts or via DB-API cursors
- Write pandas DataFrames to Treasure Data tables using bulk import, INSERT INTO, or Spark writer
- Migrate from the deprecated pandas-td package while maintaining compatible function signatures
- Perform iterative data retrieval in Jupyter notebooks to avoid Presto timeout errors on large result sets
- Access Treasure Data's Plazma primary storage directly via PySpark for high-volume analytical workloads
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
pytd provides Python interfaces to Treasure Data's REST APIs, Presto query engine, and Plazma storage, enabling efficient read/write operations on large data volumes through pandas DataFrames.
Yes. pytd is actively maintained, has no known vulnerabilities, uses a permissive license, and offers low install friction. It is the recommended Python client for analytical workflows and efficient data movement with Treasure Data. Install it if you need to query Treasure Data or write pandas DataFrames to it; use td-client-python instead if you only need basic REST API operations.
Install
pytd on PyPI
pip
pip install pytduv
uv add pytdpoetry
poetry add pytdInstalling pytd
Before you install
Low install friction with a pure-wheel distribution. Active maintenance with recent commits and stable production status. Requires Python 3.10 or later and pandas 2.1 or later.
License in practice
Apache-2.0 permissive license allows commercial and private use with minimal restrictions.
Quickstart
pip install pytd
import pytd
client = pytd.Client(database='sample_datasets')
result = client.query('select symbol, count(1) as cnt from nasdaq group by 1')
Requires TD_API_KEY and TD_API_SERVER environment variables, or explicit apikey and endpoint parameters. Python 3.10+ and pandas 2.1+ required.
Verify before relying
- Whether Presto or Hive query performance characteristics are documented for typical data volumes
- Current status and migration path for deprecated spark writer option
- Whether DB-API cursor.description field is reliably populated across all query types
Package facts
| License | Apache-2.0 (permissive) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 8 — urllib3, trino, pandas, numpy, td-client, pytz, tqdm, pyarrow |
| Maintenance | actively maintained — 192 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 352,031/month — #7,316 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: pytd-2.4.0-py3-none-any.whl
Keywords: database, treasure-data
Tags
More Database packages
psycopg2-binary is a PostgreSQL database…
copyleft · top 1,000 on PyPI
redisPython client library for connecting to and…
permissive · top 1,000 on PyPI
ydbYDB Python SDK is the official client library…
permissive · top 1,000 on PyPI
snowflake-connector-pythonConnects Python applications to Snowflake data…
permissive · top 1,000 on PyPI
sqlparsesqlparse tokenizes SQL text into a tree of…
permissive · top 1,000 on PyPI
dbt-adaptersProvides base adapter protocols and shared…
permissive · top 1,000 on PyPI
pandas-tdPandas-TD connects pandas DataFrames to…
permissive · top 15,000 on PyPI
td-clientPython client library for the Treasure Data…
permissive · top 15,000 on PyPI
presto-python-clientProvides a Python DBAPI-compatible client to…
permissive · top 5,000 on PyPI
PyHivePyHive provides DB-API and SQLAlchemy…
permissive · top 5,000 on PyPI
db-dtypesProvides pandas extension data types for SQL…
permissive · top 1,000 on PyPI
qpdQPD translates SQL SELECT statements into…
permissive · top 15,000 on PyPI
fastparquetfastparquet reads and writes Apache Parquet…
permissive · top 5,000 on PyPI
presto-types-parserParses Presto SQL type annotations from rows…
permissive · top 15,000 on PyPI
QuandlQuandl provides a Python client for accessing…
permissive · top 15,000 on PyPI
pandasqlpandasql lets you query pandas DataFrames using…
unclear · top 5,000 on PyPI