mirror of
https://github.com/grillazz/fastapi-sqlalchemy-asyncpg.git
synced 2025-08-26 16:40:40 +03:00
Merge pull request #19 from grillazz/json-field-example
move await engine.dispose() to test client
This commit is contained in:
commit
b3758a1ea3
@ -32,3 +32,6 @@ async def client() -> AsyncClient:
|
||||
) as client:
|
||||
await start_db()
|
||||
yield client
|
||||
# for AsyncEngine created in function scope, close and
|
||||
# clean-up pooled connections
|
||||
await engine.dispose()
|
||||
|
@ -31,6 +31,4 @@ async def get_db() -> AsyncGenerator:
|
||||
raise ex
|
||||
finally:
|
||||
await session.close()
|
||||
# for AsyncEngine created in function scope, close and
|
||||
# clean-up pooled connections
|
||||
await engine.dispose()
|
||||
|
||||
|
@ -17,6 +17,7 @@ app.include_router(nonsense_router)
|
||||
async def start_db():
|
||||
async with engine.begin() as conn:
|
||||
await conn.run_sync(Base.metadata.create_all)
|
||||
await engine.dispose()
|
||||
|
||||
|
||||
@app.on_event("startup")
|
||||
|
Loading…
x
Reference in New Issue
Block a user