refactor: Attachment 表关联字段 NS 更名为 SN

数据库侧已将 Common.Attachment 的 NS 列重命名为 SN,同步更新代码:
- db.py: upsert_attachments 的 DELETE/INSERT 改用 [SN],distinct_sn 变量与
  相关注释、日志文案统一更新
- write_attachments.py: 模块 docstring 与 convert_results_to_rows 的行列说明
  由 (NS, ...) 改为 (SN, ...);写入目标描述 Common.Attachment.SN
- README.md: 落库约定与字段表中 NS 全部改为 SN

已用 --sn 26B10 实测写入并用 SELECT [SN] 验证数据正确落库。

Co-Authored-By: WorkBuddy <workbuddy@tencent.com>
This commit is contained in:
Misaka_Company
2026-07-24 16:14:05 +08:00
parent ee566e3fbd
commit fd047e2143
3 changed files with 19 additions and 19 deletions

View File

@@ -270,16 +270,16 @@ python write_attachments.py --mode fine --enable-other
落库约定(与 `db.py` 常量、`write_attachments.py` 的转换逻辑保持一致):
- **有附件**`has_attachment=true``status=ok`):每个 `type` 写一行。
- `fine` 模式:`type` 形如 `大类:细分`,按首个冒号拆分为 `(NS, 大类, 细分)`。
- `coarse` 模式:`type` 是大类,小类统一填占位值 `` → `(NS, 大类, '无')`。
- `fine` 模式:`type` 形如 `大类:细分`,按首个冒号拆分为 `(SN, 大类, 细分)`。
- `coarse` 模式:`type` 是大类,小类统一填占位值 `` → `(SN, 大类, '无')`。
- **无附件**`has_attachment=false`,含 `empty_param` 与模型判无附件):写哨兵行
`(NS, '无附件', '无')`,下游用 `WHERE MajorCategory <> '无附件'` 取真实附件。
`(SN, '无附件', '无')`,下游用 `WHERE MajorCategory <> '无附件'` 取真实附件。
- **无法确定/失败**`has_attachment=null`,含 `not_found` / `llm_*_error` /
`db_error`):一律不写,既不当作无附件,也不留脏数据。
- **幂等**:写入时对同一总排号先删除旧行再插入本次结果(依赖 `NS, MajorCategory,
- **幂等**:写入时对同一总排号先删除旧行再插入本次结果(依赖 `SN, MajorCategory,
MinorCategory` 唯一索引),重跑安全。
目标表 `Common.Attachment` 字段:`NS`nvarchar(30),总排号/关联键)、
目标表 `Common.Attachment` 字段:`SN`nvarchar(30),总排号/关联键)、
`MajorCategory`nvarchar(40),附件大类)、`MinorCategory`nvarchar(40),附件小类),
三者均 `NOT NULL`。