Skip to content
This repository was archived by the owner on Aug 19, 2025. It is now read-only.

Commit bb5d009

Browse files
Add an example of connect/disconnect integration
1 parent bf81282 commit bb5d009

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,20 @@ await database.connect()
156156
await database.disconnect()
157157
```
158158

159+
If you're integrating against a web framework, then you'll probably want
160+
to hook into framework startup or shutdown events. For example, with
161+
Starlette you would use the following:
162+
163+
```python
164+
@app.on_event("startup")
165+
async def startup():
166+
await database.connect()
167+
168+
@app.on_event("shutdown")
169+
async def shutdown():
170+
await database.disconnect()
171+
```
172+
159173
## Test isolation
160174

161175
For strict test isolation you will always want to rollback the test database

0 commit comments

Comments
 (0)