use `insertmany`

main
nullobsi 2 years ago
parent f6036bcc7a
commit 7a8e90ead6
No known key found for this signature in database
GPG Key ID: 342661C4F68CD06D

@ -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…
Cancel
Save