So I have a table that is being updated with new columns every time a new instance of a class is being instantiated. Here's my code doing that.
query = "alter table test add column %s integer"
rows = (str(Driver.count), str(Driver.count+1))
for c in rows:
cur.execute(query, (AsIs(c),))
conn.commit()
Driver.count is the counter that is being incremented every new instance of the class. Now when I want to update the table, I use a command similar to this:
cur.execute("INSERT INTO test (str(Driver.count), str(Driver.count+1)) \
VALUES (%d, %d)" % (currentRow,currentCol));
Where the two columns I am specifying are variables. I know the above command won't work, since the column variables somehow need to be outside of the quotations, like when I specify the values to be inserted. How can I do this?
dc1, dc2, ...