I'm a newbie at SQLite for python and I'm confused about how to update a row while iterating through a table.
Here is some sample code:
import sqlite3 as lite
points = [
(1,2,3),
(4,5,6),
(7,8,9),
(10,11,12)
]
point_data = lite.connect('points.db')
cur = point_data.cursor()
cur.execute("DROP TABLE IF EXISTS points")
cur.execute("CREATE TABLE points(x1,y1,z1)")
cur.executemany("INSERT INTO points VALUES(?, ?, ?)", points)
cur.execute("SELECT * FROM points")
while True:
row = cur.fetchone()
if row == None:
break
row_sum = row[0]+row[1]+row[2]
I would like to know how to insert the row_sum as the fourth column using an UPDATE command. Do I have to define the fourth 'column' when I define the table?