@@ -14,7 +14,7 @@ PyAthena has two families of async cursors:
1414| ---| ---| ---|
1515| ** Concurrency model** | ` concurrent.futures.ThreadPoolExecutor ` | Native ` asyncio ` (` await ` / ` async for ` ) |
1616| ** Event loop** | Blocks a thread per query | Non-blocking |
17- | ** Connection** | ` connect() ` (sync) | ` aconnect ()` (async) |
17+ | ** Connection** | ` connect() ` (sync) | ` aio_connect ()` (async) |
1818| ** execute()** returns | ` (query_id, Future) ` | Awaitable cursor (self) |
1919| ** Fetch methods** | Sync (via ` Future.result() ` ) | ` await cursor.fetchone() ` for streaming cursors |
2020| ** Iteration** | ` for row in result_set ` | ` async for row in cursor ` |
@@ -29,22 +29,22 @@ from synchronous code.
2929
3030## Connection
3131
32- Use the ` aconnect ()` function to create an async connection.
32+ Use the ` aio_connect ()` function to create an async connection.
3333It returns an ` AioConnection ` that produces ` AioCursor ` instances by default.
3434
3535``` python
36- from pyathena import aconnect
36+ from pyathena import aio_connect
3737
38- conn = await aconnect (s3_staging_dir = " s3://YOUR_S3_BUCKET/path/to/" ,
38+ conn = await aio_connect (s3_staging_dir = " s3://YOUR_S3_BUCKET/path/to/" ,
3939 region_name = " us-west-2" )
4040```
4141
4242The connection supports the async context manager protocol:
4343
4444``` python
45- from pyathena import aconnect
45+ from pyathena import aio_connect
4646
47- async with await aconnect (s3_staging_dir = " s3://YOUR_S3_BUCKET/path/to/" ,
47+ async with await aio_connect (s3_staging_dir = " s3://YOUR_S3_BUCKET/path/to/" ,
4848 region_name = " us-west-2" ) as conn:
4949 cursor = conn.cursor()
5050 await cursor.execute(" SELECT 1" )
@@ -59,10 +59,10 @@ AioCursor is a native asyncio cursor that uses `await` for query execution and r
5959It follows the DB API 2.0 interface adapted for async usage.
6060
6161``` python
62- from pyathena import aconnect
62+ from pyathena import aio_connect
6363from pyathena.aio.cursor import AioCursor
6464
65- async with await aconnect (s3_staging_dir = " s3://YOUR_S3_BUCKET/path/to/" ,
65+ async with await aio_connect (s3_staging_dir = " s3://YOUR_S3_BUCKET/path/to/" ,
6666 region_name = " us-west-2" ) as conn:
6767 cursor = conn.cursor()
6868 await cursor.execute(" SELECT * FROM many_rows" )
@@ -74,9 +74,9 @@ async with await aconnect(s3_staging_dir="s3://YOUR_S3_BUCKET/path/to/",
7474The cursor supports the ` async with ` context manager:
7575
7676``` python
77- from pyathena import aconnect
77+ from pyathena import aio_connect
7878
79- async with await aconnect (s3_staging_dir = " s3://YOUR_S3_BUCKET/path/to/" ,
79+ async with await aio_connect (s3_staging_dir = " s3://YOUR_S3_BUCKET/path/to/" ,
8080 region_name = " us-west-2" ) as conn:
8181 async with conn.cursor() as cursor:
8282 await cursor.execute(" SELECT * FROM many_rows" )
@@ -86,9 +86,9 @@ async with await aconnect(s3_staging_dir="s3://YOUR_S3_BUCKET/path/to/",
8686You can iterate over results with ` async for ` :
8787
8888``` python
89- from pyathena import aconnect
89+ from pyathena import aio_connect
9090
91- async with await aconnect (s3_staging_dir = " s3://YOUR_S3_BUCKET/path/to/" ,
91+ async with await aio_connect (s3_staging_dir = " s3://YOUR_S3_BUCKET/path/to/" ,
9292 region_name = " us-west-2" ) as conn:
9393 async with conn.cursor() as cursor:
9494 await cursor.execute(" SELECT * FROM many_rows" )
@@ -99,9 +99,9 @@ async with await aconnect(s3_staging_dir="s3://YOUR_S3_BUCKET/path/to/",
9999Execution information of the query can also be retrieved:
100100
101101``` python
102- from pyathena import aconnect
102+ from pyathena import aio_connect
103103
104- async with await aconnect (s3_staging_dir = " s3://YOUR_S3_BUCKET/path/to/" ,
104+ async with await aio_connect (s3_staging_dir = " s3://YOUR_S3_BUCKET/path/to/" ,
105105 region_name = " us-west-2" ) as conn:
106106 async with conn.cursor() as cursor:
107107 await cursor.execute(" SELECT * FROM many_rows" )
@@ -121,9 +121,9 @@ async with await aconnect(s3_staging_dir="s3://YOUR_S3_BUCKET/path/to/",
121121To cancel a running query:
122122
123123``` python
124- from pyathena import aconnect
124+ from pyathena import aio_connect
125125
126- async with await aconnect (s3_staging_dir = " s3://YOUR_S3_BUCKET/path/to/" ,
126+ async with await aio_connect (s3_staging_dir = " s3://YOUR_S3_BUCKET/path/to/" ,
127127 region_name = " us-west-2" ) as conn:
128128 async with conn.cursor() as cursor:
129129 await cursor.execute(" SELECT * FROM many_rows" )
@@ -137,10 +137,10 @@ async with await aconnect(s3_staging_dir="s3://YOUR_S3_BUCKET/path/to/",
137137AioDictCursor is an AioCursor that returns rows as dictionaries with column names as keys.
138138
139139``` python
140- from pyathena import aconnect
140+ from pyathena import aio_connect
141141from pyathena.aio.cursor import AioDictCursor
142142
143- async with await aconnect (s3_staging_dir = " s3://YOUR_S3_BUCKET/path/to/" ,
143+ async with await aio_connect (s3_staging_dir = " s3://YOUR_S3_BUCKET/path/to/" ,
144144 region_name = " us-west-2" ) as conn:
145145 cursor = conn.cursor(AioDictCursor)
146146 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):
152152
153153``` python
154154from collections import OrderedDict
155- from pyathena import aconnect
155+ from pyathena import aio_connect
156156from pyathena.aio.cursor import AioDictCursor
157157
158- async with await aconnect (s3_staging_dir = " s3://YOUR_S3_BUCKET/path/to/" ,
158+ async with await aio_connect (s3_staging_dir = " s3://YOUR_S3_BUCKET/path/to/" ,
159159 region_name = " us-west-2" ) as conn:
160160 cursor = conn.cursor(AioDictCursor, dict_type = OrderedDict)
161161 await cursor.execute(" SELECT * FROM many_rows LIMIT 10" )
0 commit comments