mirror of
https://github.com/grillazz/fastapi-sqlalchemy-asyncpg.git
synced 2025-11-30 13:20:40 +03:00
for AsyncEngine created in function scope, close and clean-up pooled connections adding await engine.dispose()
This commit is contained in:
@@ -31,9 +31,7 @@ class Settings(BaseSettings):
|
||||
pg_pass: str = os.getenv("POSTGRES_PASSWORD", "")
|
||||
pg_host: str = os.getenv("SQL_HOST", "")
|
||||
pg_database: str = os.getenv("SQL_DB", "")
|
||||
pg_test_database: str = os.getenv("SQL_TEST_DB", "")
|
||||
asyncpg_url: str = f"postgresql+asyncpg://{pg_user}:{pg_pass}@{pg_host}:5432/{pg_database}"
|
||||
asyncpg_test_url: str = f"postgresql+asyncpg://{pg_user}:{pg_pass}@{pg_host}:5432/{pg_test_database}"
|
||||
|
||||
jwt_secret_key: str = os.getenv("SECRET_KEY", "")
|
||||
jwt_algorithm: str = os.getenv("ALGORITHM", "")
|
||||
|
||||
@@ -31,3 +31,6 @@ 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()
|
||||
|
||||
Reference in New Issue
Block a user