From 9fe598c86ee52eb3f73f954d56cc8f2509640c82 Mon Sep 17 00:00:00 2001 From: laughingman7743 Date: Sun, 22 Feb 2026 00:26:52 +0900 Subject: [PATCH] Rename aconnect to aio_connect for consistency with Aio* class naming All async classes use the `Aio` prefix (AioConnection, AioCursor, etc.) but the factory function used just `a` as prefix. Rename to `aio_connect` to align with the established naming convention. No deprecated alias is added since `aconnect` was only introduced in v3.29.0. Co-Authored-By: Claude Opus 4.6 --- README.md | 4 ++-- docs/aio.md | 40 +++++++++++++++---------------- docs/api/aio.rst | 2 +- docs/arrow.md | 24 +++++++++---------- docs/pandas.md | 16 ++++++------- docs/polars.md | 20 ++++++++-------- docs/s3fs.md | 12 +++++----- docs/spark.md | 12 +++++----- pyathena/__init__.py | 4 ++-- pyathena/aio/arrow/cursor.py | 2 +- pyathena/aio/pandas/cursor.py | 2 +- pyathena/aio/polars/cursor.py | 2 +- pyathena/aio/s3fs/cursor.py | 2 +- pyathena/aio/spark/cursor.py | 2 +- tests/pyathena/aio/conftest.py | 4 ++-- tests/pyathena/aio/test_cursor.py | 6 ++--- 16 files changed, 77 insertions(+), 77 deletions(-) diff --git a/README.md b/README.md index 015109ea..4b1edf9f 100644 --- a/README.md +++ b/README.md @@ -56,10 +56,10 @@ Native asyncio is also supported: ```python import asyncio -from pyathena import aconnect +from pyathena import aio_connect async def main(): - async with await aconnect(s3_staging_dir="s3://YOUR_S3_BUCKET/path/to/", + 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") diff --git a/docs/aio.md b/docs/aio.md index f33415a5..cd3bb22d 100644 --- a/docs/aio.md +++ b/docs/aio.md @@ -14,7 +14,7 @@ PyAthena has two families of async cursors: |---|---|---| | **Concurrency model** | `concurrent.futures.ThreadPoolExecutor` | Native `asyncio` (`await` / `async for`) | | **Event loop** | Blocks a thread per query | Non-blocking | -| **Connection** | `connect()` (sync) | `aconnect()` (async) | +| **Connection** | `connect()` (sync) | `aio_connect()` (async) | | **execute()** returns | `(query_id, Future)` | Awaitable cursor (self) | | **Fetch methods** | Sync (via `Future.result()`) | `await cursor.fetchone()` for streaming cursors | | **Iteration** | `for row in result_set` | `async for row in cursor` | @@ -29,22 +29,22 @@ from synchronous code. ## Connection -Use the `aconnect()` function to create an async connection. +Use the `aio_connect()` function to create an async connection. It returns an `AioConnection` that produces `AioCursor` instances by default. ```python -from pyathena import aconnect +from pyathena import aio_connect -conn = await aconnect(s3_staging_dir="s3://YOUR_S3_BUCKET/path/to/", +conn = await aio_connect(s3_staging_dir="s3://YOUR_S3_BUCKET/path/to/", region_name="us-west-2") ``` The connection supports the async context manager protocol: ```python -from pyathena import aconnect +from pyathena import aio_connect -async with await aconnect(s3_staging_dir="s3://YOUR_S3_BUCKET/path/to/", +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") @@ -59,10 +59,10 @@ AioCursor is a native asyncio cursor that uses `await` for query execution and r It follows the DB API 2.0 interface adapted for async usage. ```python -from pyathena import aconnect +from pyathena import aio_connect from pyathena.aio.cursor import AioCursor -async with await aconnect(s3_staging_dir="s3://YOUR_S3_BUCKET/path/to/", +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 * FROM many_rows") @@ -74,9 +74,9 @@ async with await aconnect(s3_staging_dir="s3://YOUR_S3_BUCKET/path/to/", The cursor supports the `async with` context manager: ```python -from pyathena import aconnect +from pyathena import aio_connect -async with await aconnect(s3_staging_dir="s3://YOUR_S3_BUCKET/path/to/", +async with await aio_connect(s3_staging_dir="s3://YOUR_S3_BUCKET/path/to/", region_name="us-west-2") as conn: async with conn.cursor() as cursor: await cursor.execute("SELECT * FROM many_rows") @@ -86,9 +86,9 @@ async with await aconnect(s3_staging_dir="s3://YOUR_S3_BUCKET/path/to/", You can iterate over results with `async for`: ```python -from pyathena import aconnect +from pyathena import aio_connect -async with await aconnect(s3_staging_dir="s3://YOUR_S3_BUCKET/path/to/", +async with await aio_connect(s3_staging_dir="s3://YOUR_S3_BUCKET/path/to/", region_name="us-west-2") as conn: async with conn.cursor() as cursor: await cursor.execute("SELECT * FROM many_rows") @@ -99,9 +99,9 @@ async with await aconnect(s3_staging_dir="s3://YOUR_S3_BUCKET/path/to/", Execution information of the query can also be retrieved: ```python -from pyathena import aconnect +from pyathena import aio_connect -async with await aconnect(s3_staging_dir="s3://YOUR_S3_BUCKET/path/to/", +async with await aio_connect(s3_staging_dir="s3://YOUR_S3_BUCKET/path/to/", region_name="us-west-2") as conn: async with conn.cursor() as cursor: await cursor.execute("SELECT * FROM many_rows") @@ -121,9 +121,9 @@ async with await aconnect(s3_staging_dir="s3://YOUR_S3_BUCKET/path/to/", To cancel a running query: ```python -from pyathena import aconnect +from pyathena import aio_connect -async with await aconnect(s3_staging_dir="s3://YOUR_S3_BUCKET/path/to/", +async with await aio_connect(s3_staging_dir="s3://YOUR_S3_BUCKET/path/to/", region_name="us-west-2") as conn: async with conn.cursor() as cursor: await cursor.execute("SELECT * FROM many_rows") @@ -137,10 +137,10 @@ async with await aconnect(s3_staging_dir="s3://YOUR_S3_BUCKET/path/to/", AioDictCursor is an AioCursor that returns rows as dictionaries with column names as keys. ```python -from pyathena import aconnect +from pyathena import aio_connect from pyathena.aio.cursor import AioDictCursor -async with await aconnect(s3_staging_dir="s3://YOUR_S3_BUCKET/path/to/", +async with await aio_connect(s3_staging_dir="s3://YOUR_S3_BUCKET/path/to/", region_name="us-west-2") as conn: cursor = conn.cursor(AioDictCursor) await cursor.execute("SELECT * FROM many_rows LIMIT 10") @@ -152,10 +152,10 @@ If you want to change the dictionary type (e.g., use OrderedDict): ```python from collections import OrderedDict -from pyathena import aconnect +from pyathena import aio_connect from pyathena.aio.cursor import AioDictCursor -async with await aconnect(s3_staging_dir="s3://YOUR_S3_BUCKET/path/to/", +async with await aio_connect(s3_staging_dir="s3://YOUR_S3_BUCKET/path/to/", region_name="us-west-2") as conn: cursor = conn.cursor(AioDictCursor, dict_type=OrderedDict) await cursor.execute("SELECT * FROM many_rows LIMIT 10") diff --git a/docs/api/aio.rst b/docs/api/aio.rst index 4124a255..2b43661c 100644 --- a/docs/api/aio.rst +++ b/docs/api/aio.rst @@ -9,7 +9,7 @@ Connection ---------- .. automodule:: pyathena - :members: aconnect + :members: aio_connect .. autoclass:: pyathena.aio.connection.AioConnection :members: diff --git a/docs/arrow.md b/docs/arrow.md index 419808fc..5a280d6e 100644 --- a/docs/arrow.md +++ b/docs/arrow.md @@ -491,10 +491,10 @@ Unlike AsyncArrowCursor which uses `concurrent.futures`, this cursor uses keeping the event loop free. ```python -from pyathena import aconnect +from pyathena import aio_connect from pyathena.aio.arrow.cursor import AioArrowCursor -async with await aconnect(s3_staging_dir="s3://YOUR_S3_BUCKET/path/to/", +async with await aio_connect(s3_staging_dir="s3://YOUR_S3_BUCKET/path/to/", region_name="us-west-2") as conn: cursor = conn.cursor(AioArrowCursor) table = (await cursor.execute("SELECT * FROM many_rows")).as_arrow() @@ -507,10 +507,10 @@ async with await aconnect(s3_staging_dir="s3://YOUR_S3_BUCKET/path/to/", Support fetch and iterate query results: ```python -from pyathena import aconnect +from pyathena import aio_connect from pyathena.aio.arrow.cursor import AioArrowCursor -async with await aconnect(s3_staging_dir="s3://YOUR_S3_BUCKET/path/to/", +async with await aio_connect(s3_staging_dir="s3://YOUR_S3_BUCKET/path/to/", region_name="us-west-2") as conn: cursor = conn.cursor(AioArrowCursor) await cursor.execute("SELECT * FROM many_rows") @@ -520,10 +520,10 @@ async with await aconnect(s3_staging_dir="s3://YOUR_S3_BUCKET/path/to/", ``` ```python -from pyathena import aconnect +from pyathena import aio_connect from pyathena.aio.arrow.cursor import AioArrowCursor -async with await aconnect(s3_staging_dir="s3://YOUR_S3_BUCKET/path/to/", +async with await aio_connect(s3_staging_dir="s3://YOUR_S3_BUCKET/path/to/", region_name="us-west-2") as conn: cursor = conn.cursor(AioArrowCursor) await cursor.execute("SELECT * FROM many_rows") @@ -534,10 +534,10 @@ async with await aconnect(s3_staging_dir="s3://YOUR_S3_BUCKET/path/to/", The `as_polars()` method converts the result to a Polars DataFrame: ```python -from pyathena import aconnect +from pyathena import aio_connect from pyathena.aio.arrow.cursor import AioArrowCursor -async with await aconnect(s3_staging_dir="s3://YOUR_S3_BUCKET/path/to/", +async with await aio_connect(s3_staging_dir="s3://YOUR_S3_BUCKET/path/to/", region_name="us-west-2") as conn: cursor = conn.cursor(AioArrowCursor) await cursor.execute("SELECT * FROM many_rows") @@ -547,10 +547,10 @@ async with await aconnect(s3_staging_dir="s3://YOUR_S3_BUCKET/path/to/", The unload option is also available: ```python -from pyathena import aconnect +from pyathena import aio_connect from pyathena.aio.arrow.cursor import AioArrowCursor -async with await aconnect(s3_staging_dir="s3://YOUR_S3_BUCKET/path/to/", +async with await aio_connect(s3_staging_dir="s3://YOUR_S3_BUCKET/path/to/", region_name="us-west-2") as conn: cursor = conn.cursor(AioArrowCursor, unload=True) await cursor.execute("SELECT * FROM many_rows") @@ -560,10 +560,10 @@ async with await aconnect(s3_staging_dir="s3://YOUR_S3_BUCKET/path/to/", AioArrowCursor also supports S3 timeout configuration: ```python -from pyathena import aconnect +from pyathena import aio_connect from pyathena.aio.arrow.cursor import AioArrowCursor -async with await aconnect(s3_staging_dir="s3://YOUR_S3_BUCKET/path/to/", +async with await aio_connect(s3_staging_dir="s3://YOUR_S3_BUCKET/path/to/", region_name="us-west-2") as conn: cursor = conn.cursor(AioArrowCursor, connect_timeout=10.0, request_timeout=30.0) await cursor.execute("SELECT * FROM many_rows") diff --git a/docs/pandas.md b/docs/pandas.md index 4e8886cb..19253f9f 100644 --- a/docs/pandas.md +++ b/docs/pandas.md @@ -778,10 +778,10 @@ Unlike AsyncPandasCursor which uses `concurrent.futures`, this cursor uses keeping the event loop free. ```python -from pyathena import aconnect +from pyathena import aio_connect from pyathena.aio.pandas.cursor import AioPandasCursor -async with await aconnect(s3_staging_dir="s3://YOUR_S3_BUCKET/path/to/", +async with await aio_connect(s3_staging_dir="s3://YOUR_S3_BUCKET/path/to/", region_name="us-west-2") as conn: cursor = conn.cursor(AioPandasCursor) await cursor.execute("SELECT * FROM many_rows") @@ -793,10 +793,10 @@ async with await aconnect(s3_staging_dir="s3://YOUR_S3_BUCKET/path/to/", Support fetch and iterate query results: ```python -from pyathena import aconnect +from pyathena import aio_connect from pyathena.aio.pandas.cursor import AioPandasCursor -async with await aconnect(s3_staging_dir="s3://YOUR_S3_BUCKET/path/to/", +async with await aio_connect(s3_staging_dir="s3://YOUR_S3_BUCKET/path/to/", region_name="us-west-2") as conn: cursor = conn.cursor(AioPandasCursor) await cursor.execute("SELECT * FROM many_rows") @@ -806,10 +806,10 @@ async with await aconnect(s3_staging_dir="s3://YOUR_S3_BUCKET/path/to/", ``` ```python -from pyathena import aconnect +from pyathena import aio_connect from pyathena.aio.pandas.cursor import AioPandasCursor -async with await aconnect(s3_staging_dir="s3://YOUR_S3_BUCKET/path/to/", +async with await aio_connect(s3_staging_dir="s3://YOUR_S3_BUCKET/path/to/", region_name="us-west-2") as conn: cursor = conn.cursor(AioPandasCursor) await cursor.execute("SELECT * FROM many_rows") @@ -820,10 +820,10 @@ async with await aconnect(s3_staging_dir="s3://YOUR_S3_BUCKET/path/to/", The unload option is also available: ```python -from pyathena import aconnect +from pyathena import aio_connect from pyathena.aio.pandas.cursor import AioPandasCursor -async with await aconnect(s3_staging_dir="s3://YOUR_S3_BUCKET/path/to/", +async with await aio_connect(s3_staging_dir="s3://YOUR_S3_BUCKET/path/to/", region_name="us-west-2") as conn: cursor = conn.cursor(AioPandasCursor, unload=True) await cursor.execute("SELECT * FROM many_rows") diff --git a/docs/polars.md b/docs/polars.md index 6c50cab7..4bbc7710 100644 --- a/docs/polars.md +++ b/docs/polars.md @@ -585,10 +585,10 @@ Unlike AsyncPolarsCursor which uses `concurrent.futures`, this cursor uses keeping the event loop free. ```python -from pyathena import aconnect +from pyathena import aio_connect from pyathena.aio.polars.cursor import AioPolarsCursor -async with await aconnect(s3_staging_dir="s3://YOUR_S3_BUCKET/path/to/", +async with await aio_connect(s3_staging_dir="s3://YOUR_S3_BUCKET/path/to/", region_name="us-west-2") as conn: cursor = conn.cursor(AioPolarsCursor) await cursor.execute("SELECT * FROM many_rows") @@ -600,10 +600,10 @@ async with await aconnect(s3_staging_dir="s3://YOUR_S3_BUCKET/path/to/", Support fetch and iterate query results: ```python -from pyathena import aconnect +from pyathena import aio_connect from pyathena.aio.polars.cursor import AioPolarsCursor -async with await aconnect(s3_staging_dir="s3://YOUR_S3_BUCKET/path/to/", +async with await aio_connect(s3_staging_dir="s3://YOUR_S3_BUCKET/path/to/", region_name="us-west-2") as conn: cursor = conn.cursor(AioPolarsCursor) await cursor.execute("SELECT * FROM many_rows") @@ -613,10 +613,10 @@ async with await aconnect(s3_staging_dir="s3://YOUR_S3_BUCKET/path/to/", ``` ```python -from pyathena import aconnect +from pyathena import aio_connect from pyathena.aio.polars.cursor import AioPolarsCursor -async with await aconnect(s3_staging_dir="s3://YOUR_S3_BUCKET/path/to/", +async with await aio_connect(s3_staging_dir="s3://YOUR_S3_BUCKET/path/to/", region_name="us-west-2") as conn: cursor = conn.cursor(AioPolarsCursor) await cursor.execute("SELECT * FROM many_rows") @@ -627,10 +627,10 @@ async with await aconnect(s3_staging_dir="s3://YOUR_S3_BUCKET/path/to/", The `as_arrow()` method converts the result to an Apache Arrow Table: ```python -from pyathena import aconnect +from pyathena import aio_connect from pyathena.aio.polars.cursor import AioPolarsCursor -async with await aconnect(s3_staging_dir="s3://YOUR_S3_BUCKET/path/to/", +async with await aio_connect(s3_staging_dir="s3://YOUR_S3_BUCKET/path/to/", region_name="us-west-2") as conn: cursor = conn.cursor(AioPolarsCursor) await cursor.execute("SELECT * FROM many_rows") @@ -640,10 +640,10 @@ async with await aconnect(s3_staging_dir="s3://YOUR_S3_BUCKET/path/to/", The unload option is also available: ```python -from pyathena import aconnect +from pyathena import aio_connect from pyathena.aio.polars.cursor import AioPolarsCursor -async with await aconnect(s3_staging_dir="s3://YOUR_S3_BUCKET/path/to/", +async with await aio_connect(s3_staging_dir="s3://YOUR_S3_BUCKET/path/to/", region_name="us-west-2") as conn: cursor = conn.cursor(AioPolarsCursor, unload=True) await cursor.execute("SELECT * FROM many_rows") diff --git a/docs/s3fs.md b/docs/s3fs.md index 6d0ed511..8e33479f 100644 --- a/docs/s3fs.md +++ b/docs/s3fs.md @@ -380,10 +380,10 @@ Since `AthenaS3FSResultSet` lazily streams rows from S3 via a CSV reader, fetch methods are async and require `await`. ```python -from pyathena import aconnect +from pyathena import aio_connect from pyathena.aio.s3fs.cursor import AioS3FSCursor -async with await aconnect(s3_staging_dir="s3://YOUR_S3_BUCKET/path/to/", +async with await aio_connect(s3_staging_dir="s3://YOUR_S3_BUCKET/path/to/", region_name="us-west-2") as conn: cursor = conn.cursor(AioS3FSCursor) await cursor.execute("SELECT * FROM many_rows") @@ -395,10 +395,10 @@ async with await aconnect(s3_staging_dir="s3://YOUR_S3_BUCKET/path/to/", Async iteration is supported: ```python -from pyathena import aconnect +from pyathena import aio_connect from pyathena.aio.s3fs.cursor import AioS3FSCursor -async with await aconnect(s3_staging_dir="s3://YOUR_S3_BUCKET/path/to/", +async with await aio_connect(s3_staging_dir="s3://YOUR_S3_BUCKET/path/to/", region_name="us-west-2") as conn: cursor = conn.cursor(AioS3FSCursor) await cursor.execute("SELECT * FROM many_rows") @@ -409,10 +409,10 @@ async with await aconnect(s3_staging_dir="s3://YOUR_S3_BUCKET/path/to/", Execution information of the query can also be retrieved: ```python -from pyathena import aconnect +from pyathena import aio_connect from pyathena.aio.s3fs.cursor import AioS3FSCursor -async with await aconnect(s3_staging_dir="s3://YOUR_S3_BUCKET/path/to/", +async with await aio_connect(s3_staging_dir="s3://YOUR_S3_BUCKET/path/to/", region_name="us-west-2") as conn: cursor = conn.cursor(AioS3FSCursor) await cursor.execute("SELECT * FROM many_rows") diff --git a/docs/spark.md b/docs/spark.md index d2cc7e1e..6bedcb27 100644 --- a/docs/spark.md +++ b/docs/spark.md @@ -347,10 +347,10 @@ must be wrapped in `asyncio.to_thread`: ```python import asyncio -from pyathena import aconnect +from pyathena import aio_connect from pyathena.aio.spark.cursor import AioSparkCursor -async with await aconnect(work_group="YOUR_SPARK_WORKGROUP", +async with await aio_connect(work_group="YOUR_SPARK_WORKGROUP", cursor_class=AioSparkCursor) as conn: cursor = await asyncio.to_thread(conn.cursor) await cursor.execute("""spark.sql("SELECT 1").show()""") @@ -362,10 +362,10 @@ The cursor supports the async context manager for automatic session termination: ```python import asyncio import textwrap -from pyathena import aconnect +from pyathena import aio_connect from pyathena.aio.spark.cursor import AioSparkCursor -async with await aconnect(work_group="YOUR_SPARK_WORKGROUP", +async with await aio_connect(work_group="YOUR_SPARK_WORKGROUP", cursor_class=AioSparkCursor) as conn: cursor = await asyncio.to_thread(conn.cursor) async with cursor: @@ -391,10 +391,10 @@ To cancel a running calculation: ```python import asyncio -from pyathena import aconnect +from pyathena import aio_connect from pyathena.aio.spark.cursor import AioSparkCursor -async with await aconnect(work_group="YOUR_SPARK_WORKGROUP", +async with await aio_connect(work_group="YOUR_SPARK_WORKGROUP", cursor_class=AioSparkCursor) as conn: cursor = await asyncio.to_thread(conn.cursor) await cursor.cancel() diff --git a/pyathena/__init__.py b/pyathena/__init__.py index 070f8789..7e44fbf0 100644 --- a/pyathena/__init__.py +++ b/pyathena/__init__.py @@ -131,7 +131,7 @@ def connect(*args, **kwargs) -> "Connection[Any]": return Connection(*args, **kwargs) -async def aconnect(*args, **kwargs) -> "AioConnection": +async def aio_connect(*args, **kwargs) -> "AioConnection": """Create a new async database connection to Amazon Athena. This is the async counterpart of :func:`connect`. It returns an @@ -147,7 +147,7 @@ async def aconnect(*args, **kwargs) -> "AioConnection": Example: >>> import pyathena - >>> conn = await pyathena.aconnect( + >>> conn = await pyathena.aio_connect( ... s3_staging_dir='s3://my-bucket/staging/', ... region_name='us-east-1', ... ) diff --git a/pyathena/aio/arrow/cursor.py b/pyathena/aio/arrow/cursor.py index caf4837d..ae43531d 100644 --- a/pyathena/aio/arrow/cursor.py +++ b/pyathena/aio/arrow/cursor.py @@ -29,7 +29,7 @@ class AioArrowCursor(WithAsyncFetch): operations, keeping the event loop free. Example: - >>> async with await pyathena.aconnect(...) as conn: + >>> async with await pyathena.aio_connect(...) as conn: ... cursor = conn.cursor(AioArrowCursor) ... await cursor.execute("SELECT * FROM my_table") ... table = cursor.as_arrow() diff --git a/pyathena/aio/pandas/cursor.py b/pyathena/aio/pandas/cursor.py index da475832..7a6de9a2 100644 --- a/pyathena/aio/pandas/cursor.py +++ b/pyathena/aio/pandas/cursor.py @@ -40,7 +40,7 @@ class AioPandasCursor(WithAsyncFetch): when ``chunksize`` is set, as fetch calls trigger lazy S3 reads. Example: - >>> async with await pyathena.aconnect(...) as conn: + >>> async with await pyathena.aio_connect(...) as conn: ... cursor = conn.cursor(AioPandasCursor) ... await cursor.execute("SELECT * FROM my_table") ... df = cursor.as_pandas() diff --git a/pyathena/aio/polars/cursor.py b/pyathena/aio/polars/cursor.py index 5f21b3d4..538839f4 100644 --- a/pyathena/aio/polars/cursor.py +++ b/pyathena/aio/polars/cursor.py @@ -31,7 +31,7 @@ class AioPolarsCursor(WithAsyncFetch): when ``chunksize`` is set, as fetch calls trigger lazy S3 reads. Example: - >>> async with await pyathena.aconnect(...) as conn: + >>> async with await pyathena.aio_connect(...) as conn: ... cursor = conn.cursor(AioPolarsCursor) ... await cursor.execute("SELECT * FROM my_table") ... df = cursor.as_polars() diff --git a/pyathena/aio/s3fs/cursor.py b/pyathena/aio/s3fs/cursor.py index 3f04a8d7..568ee0aa 100644 --- a/pyathena/aio/s3fs/cursor.py +++ b/pyathena/aio/s3fs/cursor.py @@ -23,7 +23,7 @@ class AioS3FSCursor(WithAsyncFetch): reader, making fetch calls blocking I/O. Example: - >>> async with await pyathena.aconnect(...) as conn: + >>> async with await pyathena.aio_connect(...) as conn: ... cursor = conn.cursor(AioS3FSCursor) ... await cursor.execute("SELECT * FROM my_table") ... row = await cursor.fetchone() diff --git a/pyathena/aio/spark/cursor.py b/pyathena/aio/spark/cursor.py index f47f2b05..ab9c9865 100644 --- a/pyathena/aio/spark/cursor.py +++ b/pyathena/aio/spark/cursor.py @@ -33,7 +33,7 @@ class AioSparkCursor(SparkBaseCursor, WithCalculationExecution): Example: >>> import asyncio - >>> async with await pyathena.aconnect( + >>> async with await pyathena.aio_connect( ... work_group="spark-workgroup", ... cursor_class=AioSparkCursor, ... ) as conn: diff --git a/tests/pyathena/aio/conftest.py b/tests/pyathena/aio/conftest.py index 840ad0b0..e81b8b40 100644 --- a/tests/pyathena/aio/conftest.py +++ b/tests/pyathena/aio/conftest.py @@ -5,11 +5,11 @@ async def _aio_connect(schema_name="default", **kwargs): - from pyathena import aconnect + from pyathena import aio_connect if "work_group" not in kwargs: kwargs["work_group"] = ENV.default_work_group - return await aconnect(schema_name=schema_name, **kwargs) + return await aio_connect(schema_name=schema_name, **kwargs) @pytest.fixture diff --git a/tests/pyathena/aio/test_cursor.py b/tests/pyathena/aio/test_cursor.py index 3e4d7344..e69a72c1 100644 --- a/tests/pyathena/aio/test_cursor.py +++ b/tests/pyathena/aio/test_cursor.py @@ -159,10 +159,10 @@ async def test_open_close(self): conn = await _aio_connect() conn.close() - async def test_aconnect(self): - from pyathena import aconnect + async def test_aio_connect(self): + from pyathena import aio_connect - conn = await aconnect(work_group=ENV.default_work_group) + conn = await aio_connect(work_group=ENV.default_work_group) async with conn.cursor() as cursor: await cursor.execute("SELECT 1") assert await cursor.fetchone() == (1,)