From 3b1bf7da6771bd1d6852d3dcc1f906d5ae5c95d1 Mon Sep 17 00:00:00 2001
From: zhaoqingang <zhaoqg0118@163.com>
Date: 星期三, 12 三月 2025 13:49:12 +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