Answer the question
In order to leave comments, you need to log in
How to create a queue in Sqlite python3?
Wrote a bot that writes data to the database. Faced the following problem:
When 2 or more people turn on the bot at the same time, because sqlite does not like multi-threading, the bot simply turns off.
import sqlite3
import threading
_____________________________________
def add(self, user_id, zero_or_one):
try:
self.lock.acquire(True)
self.cursor.execute("UPDATE driver SET reg = ? WHERE user_id = ?", (zero_or_one, user_id))
return self.conn.commit()
finally:
self.lock.release()
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question