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

@@ -6,7 +6,7 @@
- has_attachment=true (status=ok):
每个 type 一行。fine 模式 type 形如 "大类:细分",按首个冒号拆成 (大类, 小类)
coarse 模式 type 是大类,小类统一填 ''
- has_attachment=false (无附件): 写哨兵行 (NS, '无附件', '')。
- has_attachment=false (无附件): 写哨兵行 (SN, '无附件', '')。
- has_attachment=null (not_found / llm_error / db_error): 不写(属"无法确定/失败")。
用法:
@@ -25,7 +25,7 @@
--id 数据库真实 ID 列(id_field),如 802
--sn 总排号列(id_column),如 26B742即原先 --id 的语义)
--ids-file 每行一个总排号(键类型 sn)
无论用哪种方式,结果均按回查到的总排号写入 Common.Attachment.NS。
无论用哪种方式,结果均按回查到的总排号写入 Common.Attachment.SN
"""
from __future__ import annotations
@@ -54,7 +54,7 @@ def convert_results_to_rows(results: list[dict], mode: str) -> tuple[list[tuple[
"""将 classify_batch 的结果列表转成可写入 Common.Attachment 的行。
返回 (rows, skipped)
rows - list[(NS, MajorCategory, MinorCategory)]
rows - list[(SN, MajorCategory, MinorCategory)]
skipped- list[总排号]has_attachment 为 Nonenot_found/失败)未写入的
"""
rows: list[tuple[str, str, str]] = []