Pyodbc on SQL Server - How can I do an insert and get the row id?

I am using pyobbc with SQL Server 2000.

I want to be able to insert a row and return a value with the extension number of an auto increasing number of rows? Any ideas?

Here is what I still have:

cursor.execute("insert into products(id, name) values ('pyodbc', 'awesome library')")
cnxn.commit()
+5
source share
1 answer

Sorry, I asked too soon, he turned to his FAQ

Use "SELECT @@ IDENTITY".

+5
source

All Articles