sansan0/TrendRadar · error · FileNotFoundError

Schema file not found: {schema_path}

Error message

Schema file not found: {schema_path}

What it means

Error "Schema file not found: {schema_path}" thrown in sansan0/TrendRadar.

Source

Thrown at trendradar/storage/sqlite_mixin.py:90

        """获取 AI 筛选 schema 文件路径"""
        return Path(__file__).parent / "ai_filter_schema.sql"

    def _init_tables(self, conn: sqlite3.Connection, db_type: str = "news") -> None:
        """
        从 schema.sql 初始化数据库表结构

        Args:
            conn: 数据库连接
            db_type: 数据库类型 ("news" 或 "rss")
        """
        schema_path = self._get_schema_path(db_type)

        if schema_path.exists():
            with open(schema_path, "r", encoding="utf-8") as f:
                schema_sql = f.read()
            conn.executescript(schema_sql)
        else:
            raise FileNotFoundError(f"Schema file not found: {schema_path}")

        # news 库额外加载 AI 筛选表结构
        if db_type == "news":
            ai_filter_schema = self._get_ai_filter_schema_path()
            if ai_filter_schema.exists():
                with open(ai_filter_schema, "r", encoding="utf-8") as f:
                    conn.executescript(f.read())

        if db_type == "rss":
            self._migrate_rss_schema(conn)

        conn.commit()

    def _migrate_rss_schema(self, conn: sqlite3.Connection) -> None:
        """迁移 rss_items 表结构(为已有数据库添加 guid 列)"""
        cursor = conn.execute("PRAGMA table_info(rss_items)")
        columns = {row[1] for row in cursor.fetchall()}
        if "guid" not in columns:

View on GitHub (pinned to 8ee26026ba)

Solutions

  1. 确认 schema SQL 文件存在于预期路径
  2. 检查安装包是否完整,必要时重新安装以恢复缺失的 schema 文件
  3. 确认 db_type 配置正确,使 _get_schema_path 解析到正确路径

Example fix

ls trendradar/storage/schema/*.sql  # 确认 schema 文件存在

When it happens

Trigger: Thrown at trendradar/storage/sqlite_mixin.py:90 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of sansan0/TrendRadar@8ee26026ba (2026-08-15). Data as JSON: /api/errors/c2765ee2ad3aa98a. Report an issue: GitHub.