#!/usr/bin/env python3 """初始化 SQLite 数据库与默认管理员。""" from __future__ import annotations import os import sys from pathlib import Path ROOT = Path(__file__).resolve().parents[1] sys.path.insert(0, str(ROOT / "panel")) os.environ.setdefault("JIEDIAN_ROOT", str(ROOT)) from db import init_db # noqa: E402 def load_env() -> dict[str, str]: env: dict[str, str] = {} for line in (ROOT / ".env").read_text(encoding="utf-8").splitlines(): line = line.strip() if not line or line.startswith("#") or "=" not in line: continue key, _, value = line.partition("=") env[key.strip()] = value.strip() return env if __name__ == "__main__": init_db(load_env()) print("数据库初始化完成")