mirror of
https://github.com/LC044/WeChatMsg
synced 2025-02-23 03:22:17 +08:00
Merge pull request #218 from hzh7/master
add except sqlite3.OperationalEror
This commit is contained in:
commit
a21e2d657a
@ -12,21 +12,22 @@ def merge_MediaMSG_databases(source_paths, target_path):
|
|||||||
if not os.path.exists(source_path):
|
if not os.path.exists(source_path):
|
||||||
break
|
break
|
||||||
db = sqlite3.connect(source_path)
|
db = sqlite3.connect(source_path)
|
||||||
db.text_factory = str
|
db.text_factory = str
|
||||||
cursor = db.cursor()
|
cursor = db.cursor()
|
||||||
sql = '''
|
|
||||||
SELECT Key,Reserved0,Buf,Reserved1,Reserved2 FROM Media;
|
|
||||||
'''
|
|
||||||
cursor.execute(sql)
|
|
||||||
result = cursor.fetchall()
|
|
||||||
# 附加源数据库
|
# 附加源数据库
|
||||||
try:
|
try:
|
||||||
|
sql = '''SELECT Key,Reserved0,Buf,Reserved1,Reserved2 FROM Media;'''
|
||||||
|
cursor.execute(sql)
|
||||||
|
result = cursor.fetchall()
|
||||||
|
|
||||||
target_cursor.executemany(
|
target_cursor.executemany(
|
||||||
"INSERT INTO Media (Key,Reserved0,Buf,Reserved1,Reserved2)"
|
"INSERT INTO Media (Key,Reserved0,Buf,Reserved1,Reserved2)"
|
||||||
"VALUES(?,?,?,?,?)",
|
"VALUES(?,?,?,?,?)",
|
||||||
result)
|
result)
|
||||||
except sqlite3.IntegrityError:
|
except sqlite3.IntegrityError:
|
||||||
print("有重复key", "跳过")
|
print("有重复key", "跳过")
|
||||||
|
except sqlite3.OperationalError:
|
||||||
|
print("no such table: Media", "跳过")
|
||||||
cursor.close()
|
cursor.close()
|
||||||
db.close()
|
db.close()
|
||||||
# 提交事务
|
# 提交事务
|
||||||
|
Loading…
Reference in New Issue
Block a user