use insertmany

This commit is contained in:
nullobsi 2022-03-11 08:25:03 -08:00
parent f6036bcc7a
commit 7a8e90ead6
No known key found for this signature in database
GPG key ID: 342661C4F68CD06D

View file

@ -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()