简体   繁体   English

在没有dsn的情况下使用RODBC连接到MS SQL

[英]Connect to Ms SQL with RODBC without dsn

I'm trying to set up a connection from ubuntu to mssql server with the RODBC package. 我正在尝试使用RODBC软件包建立从ubuntu到mssql服务器的连接。

I did make it work with RJDBC but read the speed might be much slower than ODBC so I wanted to test it. 我确实使它与RJDBC一起使用,但是读取速度可能比ODBC慢得多,所以我想对其进行测试。

I don't have a dsn available, ip port databasename usr pwd is all the information I can use. 我没有可用的dsn,ip端口数据库名usr pwd是我可以使用的所有信息。

The code used with RJDBC which works is: 与RJDBC一起使用的有效代码是:

drv <- JDBC("com.microsoft.sqlserver.jdbc.SQLServerDriver",
  "/media/sqljdbc4.jar")

RJDBC::dbConnect(drv, 'jdbc:sqlserver://ip:port;databaseName=databasename', 'usr', 'pwd') 

Tried alot around browsing different syntaxes but could not make it work. 尝试过浏览不同的语法,但无法使其正常工作。

RODBC::odbcDriverConnect('driver={SQL Server};server=ip:port;database=databasename;uid=usr;pwd=pwd)

Gives me the error: [unixODBC][Driver Manager]Data source name not found, and no default driver specified 给我错误:[unixODBC] [驱动程序管理器]找不到数据源名称,并且未指定默认驱动程序

Do I need to download drivers to the ubuntu machine? 我需要将驱动程序下载到ubuntu计算机吗? Thought they were included with the package. 以为它们已包含在包装中。

The RODBC package doesn't include drivers. RODBC软件包不包含驱动程序。 That would be unwieldy given how many possibilities there are. 考虑到存在许多可能性,这将是不方便的。 see https://cran.r-project.org/web/packages/RODBC/vignettes/RODBC.pdf 参见https://cran.r-project.org/web/packages/RODBC/vignettes/RODBC.pdf

"connection to the particular DBMS needs an ODBC driver : these may come with the DBMS or the ODBC driver manager or be provided separately by the DBMS developers, and there are third-party developers" “与特定DBMS的连接需要ODBC驱动程序:这些驱动程序可能与DBMS或ODBC驱动程序管理器一起提供,或者由DBMS开发人员单独提供,并且有第三方开发人员”

Microsoft provides drivers for Ubuntu: https://www.microsoft.com/en-us/download/details.aspx?id=50419 Microsoft提供了适用于Ubuntu的驱动程序: https : //www.microsoft.com/zh-cn/download/details.aspx? id =50419

You can add dsn entries to the /etc/odbc.ini file in most linux distros. 您可以在大多数Linux发行版中将dsn条目添加到/etc/odbc.ini文件中。 See this for ubuntu https://help.ubuntu.com/community/ODBC 有关ubuntu的内容,请参见https://help.ubuntu.com/community/ODBC

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM