The following works as expected, however, I'm stuck on referencing the specific column names. For example, print just [OD-Nr]
or [OD-Title]
I know if I used an alias, it would be as simple as print(row.id)
, but I'd rather avoid aliases if possible.
import pyodbc
conn = pyodbc.connect('Driver={SQL Server};'
'Server=xxxx;'
'Database=xxxx;'
'UID=xxxx;'
'PWD=xxxx;')
cursor = conn.cursor()
cursor.execute("Select [OD-Nr],[OD-Title] from [dbo].[OD]")
for row in cursor:
print(row)
Any direction would be appreciated.