使用 pyodbc 连接SQLserver
from sqlalchemy import create_engine
server = '192.168.1.1' #默认可以省略端口号
username = '***'
password = '**'
database = '*'
driver = 'SQL Server'
c_ine = f"mssql+pyodbc://{username}:{password}@{server}/{database}?driver={driver}"
engine = create_engine(c_ine)
with engine.connect() as conn:
sql = "SELECT * FROM Tab"
data = conn.execute(sql)
print(list(data))