我有这段代码,但无法访问最后一个插入rowid。相反,我得到一个像m或s的字母作为id。什么可能是错的?
conn.execute('''CREATE TABLE input1 (id integer primary key autoincrement ,
name)''')
conn.execute("INSERT INTO INPUT1 (NAME) VALUES (?);", (name3,))
conn.commit()
rows =[]
for row in conn.execute('SELECT * FROM INPUT1 WHERE ID = (SELECT MAX(ID) FROM INPUT1);'):
id = id[0]
rows.append((id))
print(id)
break
答案 0 :(得分:0)
试试此代码
//
cursor=conn.cursor()
cursor.execute(INSERT INTO INPUT1 (NAME) VALUES (?);", (name3,))
print(cursor.lastrowid)