feat: 增加 YAML 配置与一键启动脚本

This commit is contained in:
caoxiaozhu
2026-07-21 16:15:01 +08:00
parent a5fbe5130a
commit 7c38e37b23
15 changed files with 954 additions and 71 deletions

View File

@@ -78,7 +78,10 @@ def verify_password(password: str, stored: str) -> tuple[bool, bool]:
def _psycopg_url(database_url: str) -> str:
return database_url.replace("postgresql+psycopg://", "postgresql://")
sqlalchemy_prefix = "postgresql+psycopg://"
if database_url.startswith(sqlalchemy_prefix):
return f"postgresql://{database_url[len(sqlalchemy_prefix):]}"
return database_url
def _pg_sql(sql: str) -> str:
@@ -1147,4 +1150,3 @@ def get_platform_store() -> PlatformStore:
if _store is None:
_store = PlatformStore()
return _store

View File

@@ -1,14 +1,15 @@
from __future__ import annotations
import os
from collections.abc import Generator
from contextlib import contextmanager
from sqlalchemy import create_engine
from sqlalchemy.orm import Session, sessionmaker
from app.core.config import get_settings
DATABASE_URL = os.getenv("DATABASE_URL", "postgresql+psycopg://yg_ft:change_me@localhost:15432/yg_ft")
DATABASE_URL = get_settings().database_url
engine = create_engine(
DATABASE_URL,
@@ -37,4 +38,3 @@ def session_scope() -> Generator[Session, None, None]:
raise
finally:
db.close()