0

I have this code with 2 entry boxes in tkinter which are passed through a database. I am trying to create and update query which updates the record in the database however I do not know how to create this from entry boxes. I have already researched this error. Exercise and Weight are the two entry boxes with MemberID being used to identify which record to update. This is the code

        cursor.execute('''

        UPDATE Exercises
        SET (Exercise =?, Weight = ?)
        WHERE MemberID=? ;


    ''')

The error is sqlite3.OperationalError: near "(": syntax error

1
  • 2
    Please don't change your code after someone has posted an answer. This leads to confusion Commented Mar 9, 2018 at 20:59

1 Answer 1

2

The set clause shouldn't be surrounded with parenthesis, just remove them and you should be OK:

UPDATE Exercises
SET    Exercise = ?, Weight = ?
WHERE  MemberID = ?;
Sign up to request clarification or add additional context in comments.

3 Comments

That creates an error sqlite3.ProgrammingError: Incorrect number of bindings supplied. The current statement uses 3, and there are 0 supplied.
@JohnMcNulty Well, you are using ? so you should provide the arguments to execute. How should sqlite know what to replace ? with? Read how parameterized queries work
I have now edited the question to include more code.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.