I need to read two tables in the database so I can compare them later, the code I made is giving error, because I'm passing two queries on the same connection how could I be correcting this? Thank you.
import pyodbc
conn = pyodbc.connect("DRIVER={SQL Server};Server=localhost;database=teste;uid=;pwd=")
cursor1 = conn.cursor()
cursor1.execute("select top 10 * from tab1")
cursor2 = conn.cursor()
cursor2.execute("select top 10 * from tab2")
for row in cursor1:
print(row)
for row in cursor2:
print(row)