Files
Mutual_Fund/config/deps.py
T
2026-09-08 19:17:35 +08:00

26 lines
592 B
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""FastAPI Depends 工厂:把池化会话按请求注入,用后即还。"""
from .database import milvus, mysql, neo4j, redis
async def get_db():
"""仓储/服务层用 AsyncSession(UoW):注入 BaseRepository。"""
async with mysql.get_session_factory()() as session:
yield session
async def get_mysql_conn():
async with mysql.get_session_factory()() as conn:
yield conn
def get_redis():
yield redis.client()
async def get_neo4j_session():
async with neo4j.get_session() as s:
yield s
def get_milvus():
yield milvus.client()