标签: python mysql
我在python 3中使用MySQLdb使用executemany插入多行。
executemany
现在我需要在多次插入后获取主键..
有没有办法让他们?
答案 0 :(得分:3)
您可以使用connection.insert_id()
connection.insert_id()
答案 1 :(得分:1)
使用executemany时,一次插入多行。您将使用connection.inster_id()
connection.inster_id()
要获取所有插入的ID,您必须运行另一个查询。