odbc - 在 R Studio Server 中找不到 ODBC SQL 服务器
问题描述
我正在尝试将 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 环境中不可用,或者我称它为错误的东西。这是我正在阅读的 R Server 文档
解决方案
问题不是来自unix-odbc
库。确实如你所见:
[unixODBC][Driver Manager]Can't open lib 'ODBC Driver 17 for SQL Server' : file not found
2 解决方案是尝试:
问题是找不到驱动程序。这可能是因为您的驱动程序未正确安装在您的计算机中。验证您是否遵循了安装步骤。
它也可能是由
-Wl,-rpath,<Link to your gcc driver library>
C++ 应用程序编译中缺少选项引起的。但是由于R 语言是用 C 编写的,所以这不会影响您。
推荐阅读
- php - 根据表值PHP将数据放在特定标题下
- python - 类型错误:open_file() 缺少 1 个必需的位置参数:'self'
- java - 检查两个 int 数组是否有重复元素,并从中提取重复元素之一
- python - 在 SQlite 中更改数据时出现错误;Python
- python - 从特定列中删除具有异常值的行
- python - 发生异常:TypeError 无法解压不可迭代的 NoneType 对象
- c - 为什么可以重新定义 C 库函数?
- php - 问题:当我更改文本区域的内容时,无法更新 db 值类型文本
- python - FieldError django
- java - 使用@Autowire 注入 bean 后的空值