【问题标题】:ODBC SQL server not found in R Studio Server在 R Studio Server 中找不到 ODBC SQL 服务器
【发布时间】:2018-11-26 04:18:22
【问题描述】:

我正在尝试将 Azure SQL 实例连接到在 Ubuntu 上提供的 R Studio Server。

library(DBI)

library(odbc)

con_string <- paste(c('DRIVER', "PORT", "SERVER", "DATABASE", "UID", "PWD"),
                    c('{ODBC Driver 17 for SQL Server}', 1433,
                      "mydatabase.database.secure.windows.net", "DB1",
                      "me", "foo"),
                    sep = "=", collapse = ";")


con <- DBI::dbConnect(odbc::odbc(), .connection_string = con_string)

我得到的错误:

Error: nanodbc/nanodbc.cpp:950: 01000: [unixODBC][Driver Manager]Can't open lib 'ODBC Driver 17 for SQL Server' : file not found 

我已经尝试了所有其他驱动程序:

{ODBC Driver 17 for SQL Server}
{ODBC Driver 13 for SQL Server}

我无法连接。我在其他环境中使用过pyodbc,并且能够连接到相同的字符串。

我确认 ODBC 库已安装:

ubuntu@ip-1-2-3-4:~$ sudo apt-get install unixodbc unixodbc-dev --install-suggests
Reading package lists... Done
Building dependency tree       
Reading state information... Done
unixodbc is already the newest version (2.3.1-4.1).
unixodbc-dev is already the newest version (2.3.1-4.1).
The following packages were automatically installed and are no longer required:
  linux-aws-headers-4.4.0-1048 linux-aws-headers-4.4.0-1049 linux-headers-4.4.0-1048-aws linux-headers-4.4.0-1049-aws linux-image-4.4.0-1048-aws
  linux-image-4.4.0-1049-aws
Use 'sudo apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 107 not upgraded

。似乎驱动程序在我的 R 环境中不可用,或者我称它为错误的东西。 This is the R Server docs that I'm reading

【问题讨论】:

  • 接受以下解决方案。在我的情况下,路径变量设置为错误的位置,R 库找不到 SQL Server 驱动程序。

标签: odbc rstudio-server azure-sql-server r-dbi


【解决方案1】:

问题不是来自unix-odbc 库。 确实如您所见:

[unixODBC][Driver Manager]Can't open lib 'ODBC Driver 17 for SQL Server' : file not found

尝试2个解决方案:

  • 问题是找不到驱动程序。这可能是因为您的驱动程序未正确安装在您的计算机中。验证您是否遵循了安装步骤。

  • 这也可能是由于在 C++ 应用程序的编译中缺少 -Wl,-rpath,&lt;Link to your gcc driver library&gt; 选项造成的。但由于 R 语言 是用 C 编写的,因此不会影响您。

【讨论】:

  • 您能推荐一种“验证您是否遵循安装”的方法吗?有没有什么好方法可以快速验证驱动是否已安装并正常工作?
  • @billmanH 您可以尝试在数据库中创建一个表,然后使用您的 ODBC 驱动程序使用以下命令尝试像 select * from table; 这样的查询:echo "select * from table;" | isql -v ODBC "Driver 17 for SQL Server"
  • @billmanH 如果您的客户端也在 linux 上,那么您的 /etc/odbc.ini/etc/odbcinst.ini 文件中描述了您的驱动程序的内容。 (不要忘记在发送信息之前从中删除用户名和密码)。为了重现您的错误,我需要在 /etc/odbcinst.ini file 中精确定位到我的动态库的错误路径:01000:1:0:[unixODBC][Driver Manager]Can't open lib '/home/.../libv2odbc.so' : file not found
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2016-06-18
  • 1970-01-01
  • 2012-11-18
  • 2022-06-16
  • 1970-01-01
  • 2018-08-14
  • 1970-01-01
相关资源
最近更新 更多