fix: 全脚本sqlite连接加busy_timeout防并发写锁(2026-08-27DB损坏教训,43文件75处)

This commit is contained in:
xxm
2026-08-28 01:29:37 +08:00
parent ca51cff625
commit e72fc0bd63
44 changed files with 111 additions and 0 deletions
@@ -497,6 +497,7 @@ def analyze_volume_deep(code):
DATA_DIR = Path(__file__).parent / "data"
try:
conn = sqlite3.connect(str(DATA_DIR / "mofin.db"))
conn.execute("PRAGMA busy_timeout=30000") # 2026-08-28 防并发写锁(DB损坏教训)
row = conn.execute("SELECT cache_json FROM mtf_cache WHERE code=?", (code,)).fetchone()
conn.close()
if not row:
@@ -623,6 +624,7 @@ def _calc_scores(code: str) -> dict:
try:
import sqlite3
conn = sqlite3.connect('/home/hmo/MoFin/data/mofin.db')
conn.execute("PRAGMA busy_timeout=30000") # 2026-08-28 防并发写锁(DB损坏教训)
rows = conn.execute(
"SELECT close, high, low, volume FROM stock_daily WHERE code=? ORDER BY date DESC LIMIT 30",
(code,)).fetchall()