May-10-2022, 08:36 AM
Well done, Extra. You found a good workaround.
But you missed the hint provided by @ndc85430 :
And "fetchall()" returns a list of tuples.
So in the first version of your program you could have solved it with:
But you missed the hint provided by @ndc85430 :
Is it a tuple with one item inside?
. In this kind of puzzles I always add a "print()" statement before the line with the error to see what the value is. In this case you would have seen "fetchone()" returned a tuple. (Just as the error message stated.) A tuple with one item: the value you wanted. Had you executed something like "SELECT Quantity, ID FROM ..." the tuple would have had two items.And "fetchall()" returns a list of tuples.
So in the first version of your program you could have solved it with:
#Get current Item quantity by ID cursor.execute("SELECT Quantity FROM items WHERE ID = ?",(userQueryID,)) myrecord = cursor.fetchall() currentQuantity = myrecord[0][0]