从mac osx 10.11连接到带有RODBC的MS SQL服务器

时间:2016-06-02 19:25:20

标签: sql-server r macos rodbc unixodbc

我已经下载并配置了freeTDS和unixODBC作为我与tsql和isql连接的证明。当我从RStudio下载RODBC并尝试连接mssql服务器时,我收到以下错误

[RODBC] ERROR: state IM002, code 1606386064, message [iODBC][Driver Manager]
Data source name not found and no default driver specified. Driver could not be loaded

从错误中我注意到仍在使用iODBC而不是unixODBC。然后我从RStudio卸载RODBC并转到终端尝试使用

强制RODBC使用unixODBC进行安装
export DYLD_LIBRARY_PATH=/usr/local/lib:${DYLD_LIBRARY_PATH}
R CMD INSTALL /Users/<username>/Downloads/RODBC_1.3-13.tar.gz

因此计算机知道安装在unixODBC的位置。

我得到与上面相同的错误。我不确定我是否做错了什么或者是否有其他方法让R使用unixODBC?

我也对如何使iODBC工作持开放态度。我是整体连接服务器业务的新手。

1 个答案:

答案 0 :(得分:0)

对于OS 10.13.3,我使用以下命令使用RODBC和python pymssql与MS SQL协同工作:

brew install homebrew/core/freetds091 --with-unixodbc.  
brew link --force freetds@0.91  
pip install pymssql  

然后对/Users//.odbc.ini

进行以下编辑
[SQLServer]   
Description = "my server"  
Driver = /usr/local/lib/libtdsodbc.so  
Trace=No  
Server = "my server"  
Port=1433   
TDS_Version=8.0  
Database= "my db"