The columns in my table look like this:
Name1 | Name2 | Weight | Height | Number1 | Number2
Some of the Number1 and Number2 columns are Null, and I am only trying to update the Null rows only. To do this, I have 6 lists:
List1 contains the values in Name1, in the same order
List2 contains the values in Name2, in the same order
List3 contains the values in Name1, but in a different order
List4 contains the values in Name2, but in the same order as List3
Lists 5 and 6 contains the values to be inserted in Number1 and Number2 respectively, and are in the same order as Lists 3 and 4.
So what I am trying to do is:
search the table for all the rows with Null values in Number1 AND Number2;
search Lists 3 OR 4 for values to match Name1 OR Name2, so if a match is found in list 3, the values for Number1 and Number2 should still be filled in from lists 5 and 6, respectively.
So the code I'm thinking of looks something like this:
for i in Name1:
c.execute("SELECT * FROM Mytable WHERE Number1 IS NULL")
if Name1 is List3:
c.execute("INSERT INTO Mytable (Number1, Number2)" " VALUES (?, ?)",
(List5[i], List6[i]))
elif Name2 is List4:
c.execute("INSERT INTO Mytable (Number1, Number2)" " VALUES (?, ?)",
(List5[i], List6[i]))
However, when I run it, it adds rows to the table, but no values for Number1 or Number2. Where am I going wrong?