1import pyodbc
2conn = pyodbc.connect('Driver={SQL Server};'
3 'Server=server_name;'
4 'Database=database_name;'
5 'Trusted_Connection=yes;')
6
7cursor = conn.cursor()
8cursor.execute('SELECT * FROM database_name.table')
9
10for row in cursor:
11 print(row)
12