mirror of
https://github.com/fotoente/MIsskey-ebooks-bot
synced 2024-11-22 03:13:06 +00:00
use insertmany
This commit is contained in:
parent
f6036bcc7a
commit
7a8e90ead6
1 changed files with 2 additions and 6 deletions
|
@ -325,9 +325,7 @@ def update():
|
|||
return
|
||||
|
||||
print("Insert new notes to database...")
|
||||
for note in notesList:
|
||||
database.execute("INSERT OR IGNORE INTO notes (id, text, timestamp, user_id) VALUES(?, ?, ?, ?)",
|
||||
[note["id"], note["text"], note["timestamp"], note["user_id"]])
|
||||
database.executemany("INSERT OR IGNORE INTO notes (id, text, timestamp, user_id) VALUES(?, ?, ?, ?)", [(note["id"],note["text"],note["timestamp"],note["user_id"]) for note in notesList])
|
||||
|
||||
database.commit()
|
||||
print("Notes updated!")
|
||||
|
@ -383,9 +381,7 @@ def init_bot():
|
|||
|
||||
print("Writing notes into database...")
|
||||
|
||||
for note in notesList:
|
||||
database.execute("INSERT INTO notes (id, text, timestamp, user_id) VALUES(?, ?, ?, ?)",
|
||||
[note["id"], note["text"], note["timestamp"], note["user_id"]])
|
||||
database.executemany("INSERT INTO notes (id, text, timestamp, user_id) VALUES(?, ?, ?, ?)", [(note["id"], note["text"], note["timestamp"], note["user_id"]) for note in notesList])
|
||||
|
||||
database.commit()
|
||||
database.close()
|
||||
|
|
Loading…
Reference in a new issue