Skip to content

Commit 533be67

Browse files
authored
commit insert in order to retrieve row
The documentation isn't clear that when the insert action is made that it needs to be committed. The proposed change commits the insert into the table thus if you query using SSMS you will see the record in the table.
1 parent da8bb7a commit 533be67

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

‎docs/connect/python/pyodbc/step-3-proof-of-concept-connecting-to-sql-using-pyodbc.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ In this example you will see how to execute an [INSERT](../../../t-sql/statement
6363

6464
#Sample insert query
6565
cursor.execute("INSERT SalesLT.Product (Name, ProductNumber, StandardCost, ListPrice, SellStartDate) OUTPUT INSERTED.ProductID VALUES ('SQL Server Express New 20', 'SQLEXPRESS New 20', 0, 0, CURRENT_TIMESTAMP )")
66+
cnxn.commit()
6667
row = cursor.fetchone()
6768

6869
while row:

0 commit comments

Comments
 (0)