Skip to content

Add async SQLAlchemy dialect using native asyncio cursors #673

@laughingman7743

Description

@laughingman7743

Summary

PyAthena now has native asyncio cursor implementations (pyathena/aio/) added in PRs #666, #667, #668, but the SQLAlchemy dialects (pyathena/sqlalchemy/) remain synchronous only. Adding async SQLAlchemy dialects would allow PyAthena to be used with async ORMs and frameworks that rely on SQLAlchemy's async engine (e.g., FastAPI + SQLAlchemy async session).

Background

SQLAlchemy 2.0+ supports async dialects via AdaptedConnection and AsyncDialect / create_async_engine. The existing synchronous dialects are:

Dialect Connection string Cursor
AthenaRestDialect awsathena+rest:// Cursor
AthenaPandasDialect awsathena+pandas:// PandasCursor
AthenaArrowDialect awsathena+arrow:// ArrowCursor
AthenaPolarsDialect awsathena+polars:// PolarsCursor
AthenaS3FSDialect awsathena+s3fs:// S3FSCursor

Each of these could have an async counterpart using the corresponding Aio*Cursor.

Scope

  • Implement async SQLAlchemy dialect(s) using AioConnection and native asyncio cursors
  • Connection string convention (e.g., awsathena+aiorest:// or similar)
  • Register as SQLAlchemy entry points in pyproject.toml
  • Add documentation to docs/sqlalchemy.md

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions