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 <cursoragent@cursor.com>
This commit is contained in:
@@ -101,8 +101,9 @@ def backfill_missing_key_signal_types(conn, *, monitor_type: str = KEY_MONITOR_T
|
|||||||
(mt,),
|
(mt,),
|
||||||
).fetchall()
|
).fetchall()
|
||||||
for row in rows:
|
for row in rows:
|
||||||
sym = row["symbol"]
|
# init_db 连接未设 row_factory,结果为 tuple
|
||||||
opened = (row["opened_at"] or "").strip()
|
rid, sym, opened_at = row[0], row[1], row[2]
|
||||||
|
opened = (opened_at or "").strip()
|
||||||
for signal in KEY_MONITOR_AUTO_TYPES:
|
for signal in KEY_MONITOR_AUTO_TYPES:
|
||||||
hist = conn.execute(
|
hist = conn.execute(
|
||||||
"""SELECT monitor_type FROM key_monitor_history
|
"""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
|
continue
|
||||||
conn.execute(
|
conn.execute(
|
||||||
"UPDATE trade_records SET key_signal_type=? WHERE id=?",
|
"UPDATE trade_records SET key_signal_type=? WHERE id=?",
|
||||||
(signal, row["id"]),
|
(signal, rid),
|
||||||
)
|
)
|
||||||
updated += 1
|
updated += 1
|
||||||
break
|
break
|
||||||
|
|||||||
Reference in New Issue
Block a user