最佳答案
当我尝试使用 pyodbc (在 mac 上)连接到 sql 服务器数据库时:
import pyodbc
server = '####'
database = '####'
username = '####@####'
password = '#####'
driver='{ODBC Driver 13 for SQL Server}'
pyodbc.connect('DRIVER='+driver+';SERVER='+server+';PORT=1443;DATABASE='+database+';UID='+username+';PWD='+password)
我得到以下错误:
错误: (’01000’,“[01000][ unixODBC ][驱动程序管理器]无法打开库‘ ODBC Driver 13 for SQL Server’: file not found (0)(SQLDriverConnect)”)
当我路径在实际的驱动程序位置:
driver='/usr/local/lib/libmsodbcsql.13.dylib'
起作用了!
我的 odbcinst.ini
是这样的:
[ODBC Driver 13 for SQL Server]
Description=Microsoft ODBC Driver 13 for SQL Server
Driver=/usr/local/lib/libmsodbcsql.13.dylib
UsageCount=1
我怎样才能让我的参考 driver='{ODBC Driver 13 for SQL Server}'
再次开始工作?
我最初使用 这本指南来安装驱动程序,现在我在 Mac Sierra 上使用水蟒,如果这有帮助的话?