cur1 = connection.cursor()
cur3 = connection.cursor()
cur3.execute("SELECT * FROM TABLE1")
connection.commit()
for i in range(0,totalRow-1):
row = cur3.fetchone()
if tempId.__contains__(row[0]):
cur1.execute("insert into summary (id, description, resolution) values (%s, %s, %s)",(row[0],row[1],tempResolution[tempId.index(row[0])]))
上面的代码没有给出任何错误,但数据没有插入数据库。
答案 0 :(得分:0)
而不是最后一行,试试这个:
tuple = row[0], row[1], tempResolution[tempId.index(row[0])]
cur1.executemany("insert into summary (id, description, resolution) values (?,?,?)", tuple)
如果这不起作用,请扩展您的代码,说明totalRow
,tempId.__contains__
以及row[0]
,row[1]
,tempResolution[tempId.index(row[0])]
<的类型/ p>