dmls are done!

This commit is contained in:
Bartal Læarsson
2026-02-16 15:12:09 +00:00
parent 072c162f2b
commit e36a1c79af
5 changed files with 224 additions and 0 deletions
+43
View File
@@ -0,0 +1,43 @@
import pyodbc
try:
connection = pyodbc.connect('DRIVER={ODBC Driver 17 for SQL Server};SERVER=.;DATABASE=SampleDB;Trusted_Connection=yes')
cursor = connection.cursor()
print("select before deleteing...")
cursor.execute("select * from tblCustomers")
while 1:
row = cursor.fetchone()
if not row:
break
print(row.id, row.code, row.firstName, row.lastName)
cursor.execute("delete from tblCustomers where id = 2")
connection.commit()
print("select after deleting")
cursor.execute("select * from tblCustomers")
while 1:
row = cursor.fetchone()
if not row:
break
print(row.id, row.code, row.firstName, row.lastName)
cursor.close()
connection.close()
except pyodbc.Error as ex:
print()
print("exception: ",ex)
cursor.close()
connection.close()
print()
exit()
print()