想sqlite插入一条记录后,马上获得自动生成的id编号的方法
connection=sqlite3.connect(':memory:') cursor=connection.cursor() cursor.execute('''CREATE TABLE foo (id integer primary key autoincrement , username varchar(50), password varchar(50))''') cursor.execute('INSERT INTO foo (username,password) VALUES (?,?)', ('test','test')) print(cursor.lastrowid)