Skip to content

Commit 3f09276

Browse files
NO-SNOW: Add aio notice (#2751)
1 parent dd6e503 commit 3f09276

3 files changed

Lines changed: 89 additions & 4 deletions

File tree

MANIFEST.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ include LICENSE.txt
44
include NOTICE
55
include pyproject.toml
66
include src/snowflake/connector/nanoarrow_cpp/ArrowIterator/LICENSE.txt
7+
include src/snowflake/connector/aio/README.md
78
recursive-include src/snowflake/connector py.typed *.py *.pyx *.js
89
recursive-include src/snowflake/connector/vendored LICENSE*
910

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
# Notice
2+
3+
**This component is a Preview feature provided for experimental purposes only.
4+
It is provided "AS IS" and without warranty of any kind. This module is not
5+
supported by Snowflake Support. Use of this code is at your own risk and it
6+
is not intended for production environments.**
7+
8+
## Features NOT Supported
9+
10+
11+
-`conn.errorhandler` (get/set) - no support for async errorhandlers
12+
-`enable_connection_diag=True` - no connection diagnostic
13+
-`authenticator='PAT_WITH_EXTERNAL_SESSION'` - not supported
14+
-`mfa_callback` / `password_callback` - not supported
15+
-`_probe_connection=True` - no connection diagnostic
16+
- ❌ Raw binary response handling - not supported
17+
- ❌ CRL (Certificate Revocation List) - not supported (only OCSP is supported)
18+
19+
## Installation & Import
20+
21+
Using aio version requires additional installation of `aiohttp` dependency.
22+
23+
```python
24+
# Same package, different import
25+
from snowflake.connector.aio import connect, SnowflakeConnection, DictCursor
26+
```
27+
28+
29+
## Connection Patterns
30+
31+
32+
```python
33+
# Pattern 1: Async context manager (recommended)
34+
async with connect(user='...', password='...', account='...') as conn:
35+
# Use connection
36+
pass
37+
38+
39+
# Pattern 2: Direct await
40+
conn = await connect(user='...', password='...', account='...')
41+
await conn.close()
42+
43+
44+
# Pattern 3: Manual
45+
conn = SnowflakeConnection(user='...', password='...', account='...')
46+
await conn.connect()
47+
await conn.close()
48+
```
49+
50+
51+
## Basic Operations Comparison
52+
53+
54+
| Operation | Sync | Async |
55+
|-----------|------|-------|
56+
| **Connect** | `conn = connect(...)` | `conn = await connect(...)` |
57+
| **Create cursor** | `cur = conn.cursor()` | `cur = conn.cursor()` *(same)* |
58+
| **Execute** | `cur.execute(sql)` | `await cur.execute(sql)` |
59+
| **Fetch one** | `cur.fetchone()` | `await cur.fetchone()` |
60+
| **Fetch many** | `cur.fetchmany(n)` | `await cur.fetchmany(n)` |
61+
| **Fetch all** | `cur.fetchall()` | `await cur.fetchall()` |
62+
| **Iterate** | `for row in cur:` | `async for row in cur:` |
63+
| **Commit** | `conn.commit()` | `await conn.commit()` |
64+
| **Rollback** | `conn.rollback()` | `await conn.rollback()` |
65+
| **Close** | `conn.close()` | `await conn.close()` |
66+
67+
68+
## Quick Examples
69+
70+
71+
### Simple Query
72+
73+
74+
```python
75+
import asyncio
76+
from snowflake.connector.aio import connect
77+
78+
79+
async def query_data():
80+
async with connect(user='...', password='...', account='...') as conn:
81+
async with conn.cursor() as cur:
82+
await cur.execute("SELECT * FROM table WHERE id < %s", (100,))
83+
async for row in cur:
84+
print(row)
85+
86+
87+
asyncio.run(query_data())
88+
```

src/snowflake/connector/aio/__init__.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
from __future__ import annotations
22

3-
# temporarily disable aio - SNOW-2905263
4-
raise ImportError("aio is not supported in this version of the connector")
5-
6-
73
from functools import wraps
84
from typing import Any, Coroutine, Generator, Protocol, TypeVar, runtime_checkable
95

0 commit comments

Comments
 (0)