25 lines
481 B
Python
25 lines
481 B
Python
|
|
# -*- coding: utf-8 -*-
|
||
|
|
# @Time : 2024/11/19 下午7:33
|
||
|
|
# @Author : 河瞬
|
||
|
|
# @FileName: dependencies.py
|
||
|
|
# @Software: PyCharm
|
||
|
|
from typing import Annotated
|
||
|
|
from fastapi import Depends
|
||
|
|
from database import engine
|
||
|
|
from sqlmodel import Session
|
||
|
|
from config import Settings
|
||
|
|
|
||
|
|
|
||
|
|
def get_session():
|
||
|
|
with Session(engine) as session:
|
||
|
|
yield session
|
||
|
|
|
||
|
|
|
||
|
|
def get_settings():
|
||
|
|
return Settings()
|
||
|
|
|
||
|
|
|
||
|
|
SessionDep = Annotated[Session, Depends(get_session)]
|
||
|
|
|
||
|
|
SettingsDep = get_settings()
|