In the code below row
is a tuple of 200 elements (numbers) and listOfVars
is a tuple of 200 strings that are variable names in the testTable
. tupleForm
is a list of tuples, 200 elements in each tuple.
The following code does not work. It returns a syntax error:
for row in tupleForm:
cmd = '''INSERT INTO testTable listOfVars values row'''
cur.execute(cmd)
However, the following works fine. Can someone explain why? I am finding sqlite so non-intuitive.
for row in tupleForm:
cmd = '''INSERT INTO testTable %s values %s'''%(listOfVars, row)
cur.execute(cmd)
Thanks for your help.