MySQLdb插入后获得插入id

时间:2014-05-12 13:02:44   收藏:0   阅读:394

print"ID of last record is ", int(cursor.lastrowid) #最后插入行的主键ID

 

print"ID of inserted record is ", int(conn.insert_id()) #最新插入行的主键ID,conn.insert_id()一定要在conn.commit()之前,否则会返回0

MySQLdb插入后获得插入id,布布扣,bubuko.com

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!