From 8c5b9681a9620b707172e171268d8f341b84c02f Mon Sep 17 00:00:00 2001 From: dekun Date: Thu, 11 Jun 2026 08:15:12 +0800 Subject: [PATCH] fix: backfill key_signal_type without sqlite3.Row in init_db Use tuple indices because init_db connects before row_factory is set. Co-authored-by: Cursor --- fib_key_monitor_lib.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/fib_key_monitor_lib.py b/fib_key_monitor_lib.py index 0d26893..4b30062 100644 --- a/fib_key_monitor_lib.py +++ b/fib_key_monitor_lib.py @@ -101,8 +101,9 @@ def backfill_missing_key_signal_types(conn, *, monitor_type: str = KEY_MONITOR_T (mt,), ).fetchall() for row in rows: - sym = row["symbol"] - opened = (row["opened_at"] or "").strip() + # init_db 连接未设 row_factory,结果为 tuple + rid, sym, opened_at = row[0], row[1], row[2] + opened = (opened_at or "").strip() for signal in KEY_MONITOR_AUTO_TYPES: hist = conn.execute( """SELECT monitor_type FROM key_monitor_history @@ -115,7 +116,7 @@ def backfill_missing_key_signal_types(conn, *, monitor_type: str = KEY_MONITOR_T continue conn.execute( "UPDATE trade_records SET key_signal_type=? WHERE id=?", - (signal, row["id"]), + (signal, rid), ) updated += 1 break