Skip to content

Commit

Permalink
Merge pull request #218 from hzh7/master
Browse files Browse the repository at this point in the history
add except sqlite3.OperationalEror
  • Loading branch information
LC044 authored Dec 23, 2023
2 parents 678d1d7 + 9b43177 commit a21e2d6
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions app/DataBase/merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,22 @@ def merge_MediaMSG_databases(source_paths, target_path):
if not os.path.exists(source_path):
break
db = sqlite3.connect(source_path)
db.text_factory = str
db.text_factory = str
cursor = db.cursor()
sql = '''
SELECT Key,Reserved0,Buf,Reserved1,Reserved2 FROM Media;
'''
cursor.execute(sql)
result = cursor.fetchall()
# 附加源数据库
try:
sql = '''SELECT Key,Reserved0,Buf,Reserved1,Reserved2 FROM Media;'''
cursor.execute(sql)
result = cursor.fetchall()

target_cursor.executemany(
"INSERT INTO Media (Key,Reserved0,Buf,Reserved1,Reserved2)"
"VALUES(?,?,?,?,?)",
result)
except sqlite3.IntegrityError:
print("有重复key", "跳过")
except sqlite3.OperationalError:
print("no such table: Media", "跳过")
cursor.close()
db.close()
# 提交事务
Expand Down

0 comments on commit a21e2d6

Please sign in to comment.