gpt4 book ai didi

java - Python 相当于 Java 的 statement.getGeneratedKeys()?

转载 作者:搜寻专家 更新时间:2023-10-30 21:36:59 31 4
gpt4 key购买 nike

Python的sqlite3模块中有没有类似于Java的statement.getGeneratedKeys()的API?如果没有,使用 sqlite3 在 Python 中获取最近自动生成的 key 的最佳方法是什么?

最佳答案

您需要使用 SQLite 函数 last_insert_rowid()。来自SQLite documentation :

The last_insert_rowid() function returns the ROWID of the last row insert from the database connection which invoked the function. The last_insert_rowid() SQL function is a wrapper around the sqlite3_last_insert_rowid() C/C++ interface function

关于java - Python 相当于 Java 的 statement.getGeneratedKeys()?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5156058/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com