修复持仓轮询时 SQLite database is locked 错误。
单连接复用并提交风控写入,启用 WAL 与 busy_timeout,缓存风控表 schema 初始化。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -158,8 +158,13 @@ def expire_old_plans():
|
||||
# —————————————— 设置读写 ——————————————
|
||||
|
||||
def get_db():
|
||||
conn = sqlite3.connect(DB_PATH)
|
||||
conn = sqlite3.connect(DB_PATH, timeout=30)
|
||||
conn.row_factory = sqlite3.Row
|
||||
conn.execute("PRAGMA busy_timeout=30000")
|
||||
try:
|
||||
conn.execute("PRAGMA journal_mode=WAL")
|
||||
except sqlite3.OperationalError:
|
||||
pass
|
||||
return conn
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user