fix: busy_timeout补丁回归——conn未定义改db/_conn等实际变量(18文件,知微卡t_62624130/t_f244e050发现)

This commit is contained in:
xxm
2026-08-28 14:59:41 +08:00
parent 139633d743
commit d04d9d5052
18 changed files with 28 additions and 28 deletions
+2 -2
View File
@@ -23,7 +23,7 @@ SCRIPT_DIR = Path('/home/hmo/MoFin/scripts')
def _get_db():
db = sqlite3.connect(DB_PATH)
conn.execute("PRAGMA busy_timeout=30000") # 2026-08-28 防并发写锁(DB损坏教训)
db.execute("PRAGMA busy_timeout=30000") # 2026-08-28 防并发写锁(DB损坏教训)
db.row_factory = sqlite3.Row
return db
@@ -288,7 +288,7 @@ def write_cash_log(cash_before, cash_after, frozen_before, frozen_after,
"""记录现金变更到 cash_log 表。"""
change_amount = round(cash_after - cash_before, 2) if cash_after is not None and cash_before is not None else 0
db = sqlite3.connect(DB_PATH)
conn.execute("PRAGMA busy_timeout=30000") # 2026-08-28 防并发写锁(DB损坏教训)
db.execute("PRAGMA busy_timeout=30000") # 2026-08-28 防并发写锁(DB损坏教训)
try:
cur = db.execute(
"""INSERT INTO cash_log