cursor.execute('INSERT INTO foo (username,password) VALUES (?,?)', ('blah',
    'blah'))
cursor2 = connection.cursor()
cursor2.execute('INSERT INTO foo (username,password) VALUES (?,?)', ('blah',
    'blah'))
print(cursor2.lastrowid)
print(cursor.lastrowid)
cursor.execute('INSERT INTO foo (id,username,password) VALUES (?,?,?)', (
    100, 'blah', 'blah'))
print(cursor.lastrowid)
How to retrieve inserted id after inserting row in SQLite using Python?