From 62febf63c742324d9ecb49eb2d8da813fdc70104 Mon Sep 17 00:00:00 2001 From: STDquantum <405720329@qq.com> Date: Wed, 13 Dec 2023 16:10:17 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=84=E7=90=86=E9=9F=B3=E9=A2=91=E5=90=88?= =?UTF-8?q?=E5=B9=B6=E7=9B=B8=E5=90=8C=E4=B8=A4=E8=A1=8C=E7=9A=84=E6=83=85?= =?UTF-8?q?=E5=86=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/DataBase/merge.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/app/DataBase/merge.py b/app/DataBase/merge.py index 2038a84..05d51ac 100644 --- a/app/DataBase/merge.py +++ b/app/DataBase/merge.py @@ -20,10 +20,13 @@ def merge_MediaMSG_databases(source_paths, target_path): cursor.execute(sql) result = cursor.fetchall() # 附加源数据库 - target_cursor.executemany( - "INSERT INTO Media (Key,Reserved0,Buf,Reserved1,Reserved2)" - "VALUES(?,?,?,?,?)", - result) + try: + target_cursor.executemany( + "INSERT INTO Media (Key,Reserved0,Buf,Reserved1,Reserved2)" + "VALUES(?,?,?,?,?)", + result) + except sqlite3.IntegrityError: + print("有重复key", "跳过") cursor.close() db.close() # 提交事务