PyAthena is a Python DB API 2.0 (PEP 249) client for Amazon Athena.
-
Python
- CPython 3.10, 3.11, 3.12, 3.13, 3.14
$ pip install PyAthenaExtra packages:
| Package | Install command | Version |
|---|---|---|
| SQLAlchemy | pip install PyAthena[SQLAlchemy] | >=1.0.0 |
| AioSQLAlchemy | pip install PyAthena[AioSQLAlchemy] | >=2.0.0 |
| Pandas | pip install PyAthena[Pandas] | >=1.3.0 |
| Arrow | pip install PyAthena[Arrow] | >=10.0.0 |
| Polars | pip install PyAthena[Polars] | >=1.0.0 |
from pyathena import connect cursor = connect(s3_staging_dir="s3://YOUR_S3_BUCKET/path/to/", region_name="us-west-2").cursor() cursor.execute("SELECT * FROM one_row") print(cursor.description) print(cursor.fetchall())Native asyncio is also supported:
import asyncio from pyathena import aio_connect async def main(): async with await aio_connect(s3_staging_dir="s3://YOUR_S3_BUCKET/path/to/", region_name="us-west-2") as conn: cursor = conn.cursor() await cursor.execute("SELECT 1") print(await cursor.fetchone()) asyncio.run(main())Many of the implementations in this library are based on PyHive, thanks for PyHive.
- Documentation: https://pyathena.dev/
- PyPI Releases: https://pypi.org/project/PyAthena/
- Source Code: https://github.com/pyathena-dev/PyAthena/
- Issue Tracker: https://github.com/pyathena-dev/PyAthena/issues
The PyAthena logo was generated using Nano-Banana Pro (Gemini 3 Pro Image).