如何在使用 Python 插入 MySQL 数据库后获取“id”?

如何在使用 Python 插入 MySQL 数据库后获取“id”?,第1张

我执行一个 INSERT INTO 语句

cursor.execute("INSERT INTO mytable(height) VALUES(%s)",(height))

我想得到主键。

我的表有 2 列:

id      primary, auto incrementheight  this is the other column.

插入后如何获得“id”?

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/read/1369974.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-15
下一篇 2022-06-15

发表评论

登录后才能评论
保存