Answer the question
In order to leave comments, you need to log in
Why is telegram sqlite3 database locked?
After processing incoming messages, other people's comments appeared. in the telegram channel and immediately the database is locked
main.py
from pyrogram import Client
api_id =
api_hash = ""
@app.on_message()
async def my_handler(client, message):
await message.forward("me")
app.run()
Answer the question
In order to leave comments, you need to log in
because the database is open in another file or something like that. sqlite3 works on the principle that when someone reads, other files cannot. Simply put, try to open sqlite3 only at the right moments. That is, do not write
conn = sqlite.connect(*arg)
#some code here
conn.close()
with sqlite.connect(*arg) as conn:
#some code here
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question