Search code examples
sql-serverrfreetdsrodbcunixodbc

How do I install RODBC so that is uses unixODBC?


After installing and configuring FreeTDS and unixODBC and confirming they are working correctly, I am trying to configure RODBC. However, I am getting the following results when attempting to view the ODBC data sources in the R console.

> odbcDataSources()
named character(0)

If I attempt to use the FreeTDS driver I get the following results.

>odbcDriverConnect("driver={FreeTDS};server=xx.xx.xx.xx;port=1433;database=XXXX_Analysis;trusted_connection=true;UID=********;PWD=********") :
[RODBC] ERROR: state IM003, code 0, message [iODBC][Driver Manager]Specified driver could not be loaded

Based on the error, it looks like RODBC is trying to use iODBC instead of unixODBC. I am not sure how to configure RODBC to use unixODBC.


Solution

  • The proper way to do this is to specify the odbc manager to the package's configure script, like this

    install.packages("RODBC", 
     type = "source", 
     INSTALL_opts="--configure-args='--with-odbc-manager=odbc'"
    )
    

    --with-odbc-manager=odbc indicates you want to use unixODBC
    --with-odbc-manager=iodbc indicates you want to use iODBC