I'm trying to increase an integer in a SQL database by one, but I get an error that my database is locked when running the code below:
cursor.execute("""SELECT score FROM scores WHERE name=?""", (user,)) # works
new_score = cursor.fetchone()[0] + 1 # works
params = (new_score, user)
cursor.execute("""UPDATE scores SET score=? WHERE name=?""", params) # error here
- new_score is a variable type int which is increased by one
- user is a string that is under the "name" column in the database
- scores is the table name
- score is a column name in the data base
Thanks for any help!