new to python and sqlite, so I'm trying to update my sqlite database.
I have x amount of columns on the rows filled in, the rest are null. I then wish to come back to these rows and update the columns i have yet to fill in that are null.
How do I update a row by adding in new data that has yet to be enterd?
I will show below that I've tried to find the correct row to update using WHERE and i use SET to set these new values.
The setup:
c.execute('CREATE TABLE IF NOT EXISTS PowerSysInfo(time REAL, NumOfNodes INT, NumOfBuses INT, BusLocation TEXT, PhaseNumber INT, v1 REAL, a1 REAL, phase1 INT, v2 REAL, a2 REAL, phase2 INT, v3 REAL, a3 REAL, phase3 INT)')
Enter my rows:
c.execute("INSERT INTO PowerSysInfo(time, NumOfNodes, NumOfBuses, BusLocation, PhaseNumber, v1, a1, phase1) VALUES (?, ?, ?, ?, ?, ?, ?, ?) ",
(mins, numNode, Numbus, bus, numNode, busVoltages[i], busVoltages[i+1], node))
conn.commit()
Now when i try to update the above row with:
c.execute("UPDATE PowerSysInfo SET v2 = ?, a2 = ?, phase2 = ? WHERE time = ?, BusLocation = ?", [busVoltages[i], busVoltages[i+1], node, mins, bus])
conn.commit()
I get OperationalError: near ",": syntax error
I've been looking at update statements, can't find one for exactly updating null with a variable. But why will this not work?
Thanks in advance for the help.