PyHive provides DB-API and SQLAlchemy connectors so Python programs query Hive, Presto, and Trino over their standard wire protocols.
Overview
PyHive is a collection of Python database interfaces for Apache Hive, Presto, and Trino. It exposes familiar DB-API cursors and SQLAlchemy engines so analytics and ETL code can run SQL against those engines from Python.
The DB-API layer lets you connect, execute queries, and fetch rows synchronously. Hive supports asynchronous execution with polling, log streaming, and cancellation while a query runs. Separate install extras cover each backend: Hive (with SASL or pure-sasl options), Presto, and Trino.
SQLAlchemy integration registers dialects so create_engine can target presto://, hive://, or trino+pyhive:// URLs. Connect arguments pass session properties, HTTPS protocol options, Hive configuration maps, and LDAP authentication where needed. Raw SQL is the expected path; generated SQL coverage is limited.
The maintainers describe the scope as a minimal client focused on connectivity rather than higher-level analytics features. Generic HTTP session customization is preferred over many one-off parameters. Development has moved to the Apache Kyuubi project, which continues PyHive maintenance.
Key features
- DB-API for Hive, Presto, and Trino
- SQLAlchemy engine dialects
- Async Hive queries with polling
- Session and configuration passthrough
- LDAP auth for Hive SQLAlchemy URLs
- Optional pure-sasl for newer Python
- HTTPS Presto and Trino connections
Use cases
- Python analytics against Hive
- Querying Presto from applications
- Trino access via Python
- SQLAlchemy pipelines on big-data SQL engines
- Long-running Hive jobs with log streaming