有一个sqlite等同于INSERT ...; SELECT @@ IDENTITY?如果是这样,请告诉我代码或指向我.
谢谢!
Cursor.lastrowid
>>> import sqlite3 >>> conn = sqlite3.connect(":memory:") >>> c = conn.cursor() >>> c.execute("create table t (id integer, some text);")>>> c.execute("insert into t values(1,'a');") >>> c.lastrowid 1
SELECT last_insert_rowid() -- same as select @@identity
last_insert_rowid() last_insert_rowid()函数返回调用该函数的数据库连接中最后一行插入的ROWID.last_insert_rowid()SQL函数是sqlite3_last_insert_rowid()C/C++接口函数的包装器.