0

I want to update a text value in my Database using a variable to determine the value that should be inserted. I tried many different things.

cursor.execute ("update Athens_Label_Table set " + category + " =" + self.create_entry.get())

cursor.execute ("update Athens_Label_Table set " + category + " = s% ", (self.create_entry.get())

Those two always make the program crash or tell me that there is a syntax mistake. I want the value in the "category" column to be replaced by self.create_entry.get().

Does anyone have an idea how to solve this problem. Thank you very much!

M0RIl
  • 1
  • The second version is correct, but you're missing a comma to make the parameters a tuple, and you're missing a `)` at the end. – Barmar Oct 05 '21 at 19:00
  • `(self.create_entry.get(),))` – Barmar Oct 05 '21 at 19:00
  • Thanks a lot for your answer. I applied your recommended improvements. Now the program does not crash anymore but it shows me the following error: "sqlite3.OperationalError: incomplete input". Do you know what could be wrong? – M0RIl Oct 05 '21 at 20:57
  • `= s%` should be `= ?`. Sqiite uses `?` as the placeholder, `%s` is for MySQL. – Barmar Oct 05 '21 at 20:58
  • Thanks man youre the best! ;) – M0RIl Oct 05 '21 at 20:59

0 Answers0