mirror of
https://github.com/stardrophere/InsightRadar.git
synced 2026-06-06 01:27:52 +08:00
login+ai cluster
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
# app/api/dependencies.py
|
||||
from app.database import SessionLocal
|
||||
|
||||
def get_db():
|
||||
"""
|
||||
FastAPI 依赖注入:为每个 HTTP 请求提供独立的数据库会话。
|
||||
请求处理完成后自动关闭,防止连接泄漏。
|
||||
"""
|
||||
db = SessionLocal()
|
||||
try:
|
||||
yield db
|
||||
finally:
|
||||
db.close()
|
||||
Reference in New Issue
Block a user