安装 pyodbc pip install pyodbc 代码 cnxn = pyodbc.connect('DRIVER={SQL Server};SERVER=server;DATABASE=database;UID=sa;PWD=password') cursor = cnxn.cursor() cursor.execute("select * from dbo.abc") row = cursor.fetchone() if row: print(row)