尝试使用PytDS,它比整个更复杂的环境工作。 pyodbc 更容易安装。
pyodbc
我在Ubuntu18.04上成功了
裁判: https://github.com/denisenkom/pytds
import pytds with pytds.connect('server', 'database', 'user', 'password') as conn: with conn.cursor() as cur: cur.execute("select 1") cur.fetchall()