Answer the question
In order to leave comments, you need to log in
Python sqlite how to update record in database?
cursor.execute('UPDATE KIWI SET cash =? WHERE name ="?"',(money,user))
db.commit()
this code does not update the record in the table, tell me what is the error
Answer the question
In order to leave comments, you need to log in
Remove the quotes around the last "?". In the current version, you are updating the balance of the user named "?", i.e. variable substitution does not occur.
And yes, as advised above - check what you have in the money and user variables before the request.
print('Money:', repr(money))
print('User:', repr(user))
repr() will print the string as a string constant in python, i.e. it will be possible to see normally invisible characters that may be present. For example, spaces at the end of a line.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question