Microsoft SQL Server TSQL Verbindung

ODBC Treiber von Mircrosoft Installieren dazu zunächst die Kompatibilität checken unter:

https://docs.microsoft.com/de-de/sql/connect/odbc/windows/system-requirements-installation-and-driver-files?view=sql-server-ver15#installing-microsoft-odbc-driver-for-sql-server

Installation:

https://docs.microsoft.com/de-de/sql/connect/odbc/windows/system-requirements-installation-and-driver-files?view=sql-server-ver15#installing-microsoft-odbc-driver-for-sql-server

Danach kann die pyodbc Bibliothek verwendet werden

import pyodbc 
cnxn = pyodbc.connect('DRIVER={SQL Server}; SERVER=12.23.46.7; PORT=1433; DATABASE=AdventureWords; UID=GMLLIFE19; PWD=ew54;')

cursor = cnxn.cursor()  
cursor.execute("SELECT * FROM dbo.Adressen")
row = cursor.fetchone() 
while row: 
    print (row)
    row = cursor.fetchone()