简体   繁体   English

Python是否等效于Java的statement.getGeneratedKeys()?

[英]Python's equivalent of Java's statement.getGeneratedKeys()?

Is there an API in Python's sqlite3 module similar to Java's statement.getGeneratedKeys()? Python的sqlite3模块中是否有类似于Java的statement.getGeneratedKeys()的API? If not, what is the best way to get recently autogenerated keys in Python with sqlite3? 如果不是,使用sqlite3在Python中获取最近自动生成的键的最佳方法是什么?

You need to use the SQLite function last_insert_rowid() . 您需要使用SQLite函数last_insert_rowid() From the SQLite documentation : SQLite文档中

The last_insert_rowid() function returns the ROWID of the last row insert from the database connection which invoked the function. last_insert_rowid()函数从调用该函数的数据库连接返回最后一行插入的ROWID。 The last_insert_rowid() SQL function is a wrapper around the sqlite3_last_insert_rowid() C/C++ interface function last_insert_rowid()SQL函数是sqlite3_last_insert_rowid()C / C ++接口函数的包装

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM