简体   繁体   中英

How to connect to SQL Server from R under cygwin?

I'm having some real difficulty coming up with a set of tools/configuration that works to connect to a Microsoft SQL Server from R under cygwin.

I'm using the RODBC library

I can successfully connect when I'm using R under windows using a statement like:

db.connex.string <- 'driver={SQL Server};server=machine_name;database=db_name;trusted_connection=true'
db.connex <- odbcDriverConnect(db.connex.string)

When I try the same command in R under cygwin, I get a flurry of warnings and errors that start out:

> warnings()
Warning messages:
1: In odbcDriverConnect(db.connex.string) :
[RODBC] ERROR: state 00000, code 1807981029, message [iODBC][Driver Manager]No such file or directory
2: In odbcDriverConnect(db.connex.string) :
[RODBC] ERROR: state IM003, code 1807981029, message [iODBC][Driver Manager]Specified driver could not be loaded
3: In odbcDriverConnect(db.connex.string) :
[RODBC] ERROR: state IM003, code 1807981029, message [iODBC][Driver Manager]Specified driver could not be loaded
4: In odbcDriverConnect(db.connex.string) :
[RODBC] ERROR: state IM003, code 1807981029, message [iODBC][Driver Manager]Specified driver could not be loaded

Any help is appreciated.

Under Cygwin your R is complaining that it cannot find a driver at all. Make sure you check the following:

  1. Have you installed unixodbc to manage the drivers?
  2. Are you sure you have installed an ODBC driver (like freeTDS)?
  3. And are you sure you have set the odbc.ini file with the connection details to your database server?

I have not found many references to installing odbcUnix on Cygwin , but it seems to be possible. And if it is MicroSoft SQL Server you want to connect to, they have released a MSSQL specific driver for linux that works very well on Linux and I would recommend above FreeTDS. But I do not know if it is possible to install on Cygwin.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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