我想从MSSQL表中读取内容,然后插入MySQL表中,但是我无法将MSSQL结果的格式设置为executemany
cursor.execute('select * from table') # MSSQL
rows = cursor.fetchall()
many_rows = []
for row in rows:
many_rows.append((row))
sql = "insert into mysql.table VALUES (NULL, %s) on duplicate key update REFCOLUMN=REFCOLUMN" # MYSQL
mycursor.executemany(sql, many_rows)
mydb.commit()
这给出了Failed executing the operation; Could not process parameters
第一个NULL用于id列,%s用于其他49列。它可以1比1运作,但需要花很长时间才能建立远程连接
编辑
我的示例打印输出many_rows
:
[
(49 columns' values, all string and separated by comma),
(49 columns' values, all string and separated by comma),
(49 columns' values, all string and separated by comma),
...
]
答案 0 :(得分:0)
我能够通过添加如下数据来解决我的问题:
many_rows.append((list(row)))