增加合并数据库的容错
This commit is contained in:
parent
0755a412d6
commit
ca1bb8ea59
@ -5,6 +5,7 @@
|
|||||||
# Author: xaoyaoo
|
# Author: xaoyaoo
|
||||||
# Date: 2023/12/03
|
# Date: 2023/12/03
|
||||||
# -------------------------------------------------------------------------------
|
# -------------------------------------------------------------------------------
|
||||||
|
import logging
|
||||||
import os
|
import os
|
||||||
import random
|
import random
|
||||||
import shutil
|
import shutil
|
||||||
@ -282,7 +283,11 @@ def merge_db(db_paths, save_path="merge.db", CreateTime: int = 0, endCreateTime:
|
|||||||
continue
|
continue
|
||||||
# 插入数据
|
# 插入数据
|
||||||
sql = f"INSERT OR IGNORE INTO {table} ({','.join([i[0] for i in col_type])}) VALUES ({','.join(['?'] * len(columns))})"
|
sql = f"INSERT OR IGNORE INTO {table} ({','.join([i[0] for i in col_type])}) VALUES ({','.join(['?'] * len(columns))})"
|
||||||
|
try:
|
||||||
out_cursor.executemany(sql, src_data)
|
out_cursor.executemany(sql, src_data)
|
||||||
|
except Exception as e:
|
||||||
|
logging.error(f"error: {alias}\n{table}\n{sql}\n{src_data}\n{len(src_data)}\n{e}\n**********")
|
||||||
|
raise e
|
||||||
outdb.commit()
|
outdb.commit()
|
||||||
db.close()
|
db.close()
|
||||||
outdb.close()
|
outdb.close()
|
||||||
|
Loading…
Reference in New Issue
Block a user