Compare commits
2 Commits
2f73dd07b5
...
a6873ae2ee
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a6873ae2ee | ||
|
|
8292de7747 |
@@ -3,7 +3,7 @@ from typing import Generator
|
||||
from sqlalchemy import create_engine
|
||||
from sqlalchemy.orm import DeclarativeBase, Session, sessionmaker
|
||||
|
||||
from app.core.config import settings
|
||||
from config.settings import settings
|
||||
|
||||
engine = create_engine(
|
||||
settings.database_url,
|
||||
|
||||
@@ -45,7 +45,12 @@ class Settings(BaseModel):
|
||||
|
||||
def load_settings(config_path: str = "config/settings.yaml") -> Settings:
|
||||
"""加载 YAML 配置文件"""
|
||||
# Resolve relative to the project root (where config/ directory exists)
|
||||
path = Path(config_path)
|
||||
if not path.is_absolute():
|
||||
# __file__ is config/settings.py, so parent.parent gives us project root
|
||||
project_root = Path(__file__).resolve().parent.parent
|
||||
path = project_root / config_path
|
||||
if not path.exists():
|
||||
raise FileNotFoundError(
|
||||
f"配置文件不存在: {config_path}\n"
|
||||
|
||||
Reference in New Issue
Block a user