"""40万条 synthetic archive rows; the source fixture contains no real customer data.""" from pathlib import Path import sqlite3,sys,time,json sys.path.insert(0,str(Path(__file__).resolve().parents[2]/'wechat_rpa')) import admin_backend from knowledge_store import KnowledgeStore root=Path(__file__).resolve().parent target=root/'benchmark.db' assert not target.exists(), 'Do not overwrite an existing benchmark' with sqlite3.connect(root/'backend.db') as original, sqlite3.connect(target) as db: original.backup(db) original.close() db.close() db=sqlite3.connect(target) db.execute('PRAGMA journal_mode=WAL') db.execute('PRAGMA synchronous=NORMAL') def clone(table, amount, replacements): columns=[row[1] for row in db.execute('PRAGMA table_info('+table+')')] expressions=[replacements.get(column, 'base."'+column+'"') for column in columns] db.execute('WITH RECURSIVE seq(n) AS (VALUES(0) UNION ALL SELECT n+1 FROM seq WHERE n