Answer the question
In order to leave comments, you need to log in
How to make a record in the database after accessing it?
When working with the database, I encountered an error sqlite3.OperationalError: database is locked
. The error is understandable, the database is locked, so after each call I “committed” it, but still I can’t make a record in it.
Here is the code
cur.execute(f'SELECT var FROM users WHERE user_id={user.id}')
(var,) = cur.fetchone()
con.commit()
cur.execute(f'SELECT cal FROM {usern} ')
(cal,) = cur.fetchone()
con.commit()
# здесь математические операции с данными с предыдущих запросов
update_data(usern, data)
def update_data(usern, data):
cur.execute(f'UPDATE {usern} SET (data) = (?) ',
(data ))
con.commit()
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