本文介绍了R:[unixODBC] [驱动程序管理器]无法打开lib'SQL Server':找不到文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

setwd("/mnt/mountpoint/abc/")
sqlServerConnString <- "SERVER=server;DATABASE=sqldwdb;UID=xyz;PWD=abc;"
sqlServerDataDS <- RxSqlServerData(sqlQuery = "SELECT * FROM xyz",
                               connectionString = sqlServerConnString)
sqlServerDataDF <- rxImport(sqlServerDataDS)

这是我的代码.我在R中收到Followin错误

This is my code. I am getting the followin error in R

[unixODBC] [驱动程序管理器]连接不存在ODBC错误 SQLDisconnect无法打开数据源.错误 doTryCatch(return(expr),name,parentenv,handler):无法打开 数据源.

[unixODBC][Driver Manager]Connnection does not exist ODBC Error in SQLDisconnect Could not open data source.Error in doTryCatch(return(expr), name, parentenv, handler) : Could not open data source.

我已经在我的linux机器上安装了MSSQL和unixODBC驱动程序,并且它也在/etc/odbc.ini文件中得到重新显示

I have installed MSSQL and unixODBC driver on my linux machine and it is getting refelected in /etc/odbc.ini file too

有人可以帮我吗?

推荐答案

当我将下面的代码连接到MSSQLSERVER时,我遇到了相同的错误

I got the same error when i put below code for connection to MSSQLSERVER

library(RODBC)
dbconnection <- odbcDriverConnect("Driver=SQL Server;Server=192.168.76.60; Database=kaggle;Uid=sa; Pwd=1234")

它扔给我

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

为什么会引发此错误?答:当我们无法在驱动程序值上输入正确的ODBC版本名称时.

why this Error thrown?Answer: when we fail to put proper ODBC version name on Driver value.

我们可以从此处获取Driver ODBC版本名称

在"/etc"文件夹中,您将找到"odbcinst.ini"文件,打开该文件并检查版本名称

inside "/etc" folder you will find "odbcinst.ini" file open it and check the version name

[ODBC Driver 17 for SQL Server]
Description=Microsoft ODBC Driver 17 for SQL Server
Driver=/opt/microsoft/msodbcsql17/lib64/libmsodbcsql-17.1.so.0.1
UsageCount=1

所以我从这里得到了ODBC驱动程序名称,它将是"SQL Server的ODBC驱动程序17"然后我修改我的连接字符串

so i got ODBC Driver name from here , it will be "ODBC Driver 17 for SQL Server"Then i modify my connection string

library(RODBC)
dbconnection <- odbcDriverConnect("Driver=ODBC Driver 17 for SQL Server;Server=192.168.76.60; Database=kaggle;Uid=sa; Pwd=1234")

效果很好

这篇关于R:[unixODBC] [驱动程序管理器]无法打开lib'SQL Server':找不到文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-18 09:09