python sql last insertend

Solutions on MaxInterview for python sql last insertend by the best coders in the world

showing results for - "python sql last insertend"
Carlos
18 Apr 2020
1>>> import MySQLdb
2>>> connection = MySQLdb.connect(user='root')
3>>> cursor = connection.cursor()
4>>> cursor.execute('INSERT INTO sometable VALUES (...)')
51L
6>>> connection.insert_id()
73L
8>>> cursor.lastrowid
93L
10>>> cursor.execute('SELECT last_insert_id()')
111L
12>>> cursor.fetchone()
13(3L,)
14>>> cursor.execute('select @@identity')
151L
16>>> cursor.fetchone()
17(3L,)
similar questions
queries leading to this page
python sql last insertend