()
| 20 | |
| 21 | |
| 22 | async def asyncio() -> None: |
| 23 | e = create_async_engine("sqlite://") |
| 24 | |
| 25 | assert_type(e, AsyncEngine) |
| 26 | |
| 27 | async with e.connect() as conn: |
| 28 | assert_type(conn, AsyncConnection) |
| 29 | |
| 30 | result = await conn.execute(text("select * from table")) |
| 31 | |
| 32 | assert_type(result, CursorResult[Unpack[tuple[Any, ...]]]) |
| 33 | |
| 34 | # stream with direct await |
| 35 | async_result = await conn.stream(text("select * from table")) |
| 36 | |
| 37 | assert_type(async_result, AsyncResult[Unpack[tuple[Any, ...]]]) |
| 38 | |
| 39 | # stream with context manager |
| 40 | async with conn.stream( |
| 41 | text("select * from table") |
| 42 | ) as ctx_async_result: |
| 43 | assert_type(ctx_async_result, AsyncResult[Unpack[tuple[Any, ...]]]) |
| 44 | |
| 45 | # stream_scalars with direct await |
| 46 | async_scalar_result = await conn.stream_scalars( |
| 47 | text("select * from table") |
| 48 | ) |
| 49 | |
| 50 | assert_type(async_scalar_result, AsyncScalarResult[Any]) |
| 51 | |
| 52 | # stream_scalars with context manager |
| 53 | async with conn.stream_scalars( |
| 54 | text("select * from table") |
| 55 | ) as ctx_async_scalar_result: |
| 56 | assert_type(ctx_async_scalar_result, AsyncScalarResult[Any]) |
| 57 | |
| 58 | async with e.begin() as conn: |
| 59 | assert_type(conn, AsyncConnection) |
| 60 | |
| 61 | result = await conn.execute(text("select * from table")) |
| 62 | |
| 63 | assert_type(result, CursorResult[Unpack[tuple[Any, ...]]]) |
| 64 | |
| 65 | await conn.run_sync(work_sync, 1) |
| 66 | |
| 67 | # EXPECTED_MYPY: Missing positional argument "foo" in call to "run_sync" of "AsyncConnection" |
| 68 | await conn.run_sync(work_sync) |
| 69 | |
| 70 | ce = select(1).compile(e) |
| 71 | ce.statement |
| 72 | cc = select(1).compile(conn) |
| 73 | cc.statement |
| 74 | |
| 75 | async with e.connect() as conn: |
| 76 | metadata = MetaData() |
| 77 | |
| 78 | await conn.run_sync(metadata.create_all) |
| 79 | await conn.run_sync(metadata.reflect) |
nothing calls this directly
no test coverage detected