feat: 资产 CRUD API + 统计接口 + Vue3 管理前端(可选 API Key 鉴权)
This commit is contained in:
+8
-1
@@ -1,8 +1,9 @@
|
||||
"""SQLite 数据库连接与初始化"""
|
||||
|
||||
from pathlib import Path
|
||||
from typing import Generator
|
||||
|
||||
from sqlmodel import SQLModel, create_engine
|
||||
from sqlmodel import Session, SQLModel, create_engine
|
||||
|
||||
BASE_DIR = Path(__file__).resolve().parent.parent
|
||||
DATA_DIR = BASE_DIR / "data"
|
||||
@@ -19,3 +20,9 @@ def init_db() -> None:
|
||||
from app.models.asset import AIAccount, Asset, DomainDetail, VPSDetail # noqa: F401
|
||||
|
||||
SQLModel.metadata.create_all(engine)
|
||||
|
||||
|
||||
def get_session() -> Generator[Session, None, None]:
|
||||
"""FastAPI 依赖:提供数据库会话(请求结束后自动关闭)"""
|
||||
with Session(engine) as session:
|
||||
yield session
|
||||
|
||||
Reference in New Issue
Block a user