You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
try:
# con = sql.connect(sqlite_path)
# 尝试增加等待时间解决bug: (sqlite3.OperationalError) database is locked
con = sql.connect(sqlite_path, timeout=10)
con.row_factory = sql.Row
cur = con.cursor()
tables = [x["name"] for x in cur.execute("select name from sqlite_master where type='table'").fetchall()]
for model in models:
table = model.local_table.fullname
if table not in tables:
continue
print(f"processing table: {table}")
with session_scope() as session:
for row in cur.execute(f"select * from {table}").fetchall():
data = {k: row[k] for k in row.keys() if k in model.columns}
if "create_time" in data:
data["create_time"] = parse(data["create_time"])
pprint(data)
session.add(model.class_(**data))
con.close()
return True
except Exception as e:
print(f"无法读取备份数据库:{sqlite_path}。错误信息:{e}")
return False
无论是创建新的数据库,还是向已经创建的数据库中添加文件,都会出现这个错误:kb_api.py[line:47] - ERROR: OperationalError: 创建知识库出错: (sqlite3.OperationalError) database is locked
The text was updated successfully, but these errors were encountered: