在mysql python中,将列表的每个元素插入到单独的列中

2024-04-29 19:25:12 发布

您现在位置:Python中文网/ 问答频道 /正文

我希望能够迭代python中的列表,并将每个元素插入MySQL数据库中表的单独列中。在

我有这个语法,我在这里也找到了:

 jobdata = [sampledata,sampledata1,sampledata2]

 params = ['?' for item in jobdata]
 sql   = 'INSERT INTO refactorBatch (runnum, hold, processtn) VALUES (%s);' % ','.join(params)
 cursor.execute(sql, list)
 cnx.commit()

但我有个错误:

^{pr2}$

我错过什么了吗?在

谢谢你!在


Tags: in数据库元素列表forsqlmysql语法