From 226202d6eee6480f3386c6295be26fad42940cc8 Mon Sep 17 00:00:00 2001
From: zhaoqingang <zhaoqg0118@163.com>
Date: 星期五, 28 三月 2025 09:41:39 +0800
Subject: [PATCH] 知识库分享,历史记录文件
---
app/models/postgresql_base_model.py | 8 ++++++--
1 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/app/models/postgresql_base_model.py b/app/models/postgresql_base_model.py
index f139db8..f6caf45 100644
--- a/app/models/postgresql_base_model.py
+++ b/app/models/postgresql_base_model.py
@@ -7,11 +7,15 @@
DATABASE_URL = os.getenv('POSTGRESQL_DATABASE_URL') or settings.postgresql_database_url
-engine = create_async_engine(DATABASE_URL, echo=True)
+engine = create_async_engine(DATABASE_URL, echo=False)
PostgresqlSessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine, class_=AsyncSession)
PostgresqlBase = declarative_base()
async def get_pdb() -> AsyncSession:
async with PostgresqlSessionLocal() as session:
- yield session
\ No newline at end of file
+ # yield session
+ try:
+ yield session
+ finally:
+ session.close()
\ No newline at end of file
--
Gitblit v1.8.0