0

I want to update a column in my SQLite database. I need to a list of values to my column. Tried to search on Stackowerflow and I found an article, from which I got this code:

cur.executemany("""UPDATE Details SET Stock = Stock + ? WHERE %s"""% condition, (i,))

But it didn't work in my case and I got this error:

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

I tried different ways to do it, but the best result was to update entire column with last element in my list.

  • unless you're using negative values, I don't see any subtraction in there... what exactly are you trying to do? Update multiple stock values for multiple different items? – Marc B Aug 18 '16 at 21:53
  • @MarcB, oh, sorry not to subtract, to add list of values to my column. – Oleksandr Ivanenko Aug 18 '16 at 21:56
  • so "item #1 -> +7, item #2 -> +42, etc...? you don't do that with a single query unless you want to write a massively ugly `set stock = case when id=1 then stock + 7 when id=2 then stock +42`type thing. you update each record individually. – Marc B Aug 18 '16 at 21:57

0 Answers0