Skip to content

Commit 52c082f

Browse files
authored
docs: update prefect-sqlalchemy async examples to use AsyncSqlAlchemyConnector (#20654)
1 parent 7255ed5 commit 52c082f

File tree

2 files changed

+8
-17
lines changed

2 files changed

+8
-17
lines changed

docs/integrations/prefect-sqlalchemy/index.mdx

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -91,21 +91,8 @@ Use the `SqlAlchemyConnector` as a context manager, to ensure that the SQLAlchem
9191

9292
**Async support**
9393

94-
`SqlAlchemyConnector` supports async workflows. Just be sure to save, load, and use an async driver, as in the example below.
94+
For async workflows with async database drivers (like `AsyncDriver.SQLITE_AIOSQLITE` or `AsyncDriver.POSTGRESQL_ASYNCPG`), use `AsyncSqlAlchemyConnector` instead of `SqlAlchemyConnector`. See the **Async** tab below for a complete example.
9595

96-
```python
97-
from prefect_sqlalchemy import SqlAlchemyConnector, ConnectionComponents, AsyncDriver
98-
99-
connector = SqlAlchemyConnector(
100-
connection_info=ConnectionComponents(
101-
driver=AsyncDriver.SQLITE_AIOSQLITE,
102-
database="DATABASE-PLACEHOLDER.db"
103-
)
104-
)
105-
106-
if __name__ == "__main__":
107-
connector.save("BLOCK_NAME-PLACEHOLDER")
108-
```
10996
</Note>
11097

11198
<Tabs>
@@ -164,13 +151,13 @@ if __name__ == "__main__":
164151

165152
```python
166153
from prefect import flow, task
167-
from prefect_sqlalchemy import SqlAlchemyConnector
154+
from prefect_sqlalchemy import AsyncSqlAlchemyConnector
168155
import asyncio
169156

170157

171158
@task
172159
async def setup_table(block_name: str) -> None:
173-
async with await SqlAlchemyConnector.load(block_name) as connector:
160+
async with await AsyncSqlAlchemyConnector.load(block_name) as connector:
174161
await connector.execute(
175162
"CREATE TABLE IF NOT EXISTS customers (name varchar, address varchar);"
176163
)
@@ -189,7 +176,7 @@ async def setup_table(block_name: str) -> None:
189176
@task
190177
async def fetch_data(block_name: str) -> list:
191178
all_rows = []
192-
async with await SqlAlchemyConnector.load(block_name) as connector:
179+
async with await AsyncSqlAlchemyConnector.load(block_name) as connector:
193180
while True:
194181
# Repeated fetch* calls using the same operation will
195182
# skip re-executing and instead return the next set of results

docs/v3/release-notes/index.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,17 @@ Release notes for Prefect integrations.
2828
- [prefect-aws](/v3/release-notes/integrations/prefect-aws)
2929
- [prefect-azure](/v3/release-notes/integrations/prefect-azure)
3030
- [prefect-bitbucket](/v3/release-notes/integrations/prefect-bitbucket)
31+
- [prefect-databricks](/v3/release-notes/integrations/prefect-databricks)
3132
- [prefect-dbt](/v3/release-notes/integrations/prefect-dbt)
3233
- [prefect-docker](/v3/release-notes/integrations/prefect-docker)
3334
- [prefect-gcp](/v3/release-notes/integrations/prefect-gcp)
3435
- [prefect-github](/v3/release-notes/integrations/prefect-github)
3536
- [prefect-gitlab](/v3/release-notes/integrations/prefect-gitlab)
3637
- [prefect-kubernetes](/v3/release-notes/integrations/prefect-kubernetes)
3738
- [prefect-redis](/v3/release-notes/integrations/prefect-redis)
39+
- [prefect-shell](/v3/release-notes/integrations/prefect-shell)
40+
- [prefect-snowflake](/v3/release-notes/integrations/prefect-snowflake)
41+
- [prefect-sqlalchemy](/v3/release-notes/integrations/prefect-sqlalchemy)
3842

3943

4044
## Prefect Cloud

0 commit comments

Comments
 (0)