1

I'm working on a project for computer science, where I have to make a database program using SQLite3 with GUI (so I use tkinter)

Now I want to change the value of an item in a table with a WHERE statement, but this doesn't work. This is my code (I already connected with the database).

def show():
    Name = tk.Label(self, text="Name")
    Name.grid(row=2, column=0)
    NameA = tk.Entry(self)
    NameA.grid(row=2, column=1)
    var1 = tk.IntVar()
    vijfprA = tk.Checkbutton(self, text="Vijf procent", variable=var1)
    vijfprA.grid(row=4, column=1)

def veranderen():
    if var1.get() == 1:
        koe = NameA.get()
        c.execute('''UPDATE reserveringen SET deelbetaald = "Yes" WHERE 
        naamgezelschap = (?)''', (koe))
        conn.commit()

button2 = tk.Button(self, text="Invoegen", command=veranderen)
button2.grid(row=5, column=1)

This is only the part where the error starts. This is the error I get:

> sqlite3.ProgrammingError: Incorrect number of bindings supplied. The current statement uses 1, and there are 8 supplied.

Thanks!!

1
  • It's telling that whatever koe is, it has 8 values, but your SQL only allows for 1. Which of those values do you want to use? Commented Jun 26, 2017 at 12:28

1 Answer 1

1

(koe) is a single value, (koe,) is a tuple. The method c.execute requires a tuple:

c.execute('''UPDATE reserveringen SET deelbetaald = "Yes" WHERE 
    naamgezelschap = (?)''', (koe,))
Sign up to request clarification or add additional context in comments.

Comments

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.