tom
tom

Reputation: 205

RODBC on macOS Catalina

I'm having trouble getting RODBC to work on macOS Catalina. I'm trying to connect to MS SQL Server. I have installed unixODBC using Homebrew and installed the Microsoft ODBC drivers from here. RODBC installs fine, and I installed it using this as suggested elsewhere:

install.packages('RODBC', type="source", configure.args='--with-odbc-include=/usr/local/lib' )

But when I run this:

RODBC::odbcDriverConnect(connection = "driver={ODBC Driver 17 for SQL Server};server=XYZ;database=XYZ;UID=XYZ;PWD=XYZ")

it hangs -- I have to cancel the command, and then I get a bunch of warnings that look like this:

[RODBC] ERROR: state IM003, code 0, message [iODBC][Driver Manager]Specified driver could not be loaded

I know that the SQL Server driver is installed, since using the ODBC package in R works -- with the same driver! But for some reason RODBC is using iODBC, and is apparently looking in the wrong place for the driver.

I'm trying to write code that will run on different platforms, and I've successfully used RODBC on Ubuntu and Windows. But I'm having a tough time figuring out how to get RODBC to work on my MacBook.

Upvotes: 2

Views: 1309

Answers (1)

AlbertG
AlbertG

Reputation: 76

I had the same issue connecting with Impala on Mac after some upgrades. The workaround was to make sure RODBC used unixodbc instead of iODBC as follows:

  • install unixodbc. I used brew.
  • Remove RODBC with remove.packages("RODBC")
  • Reinstall RODBC from source and specify the path to unixodbc lib and include with install.packages("RODBC", type = "source", configure.args = c("--with-odbc-include=/usr/local/include/","--with-odbc-lib=/usr/local/lib/") )

On my computer unixodbc is in /usr/local

Upvotes: 6

Related Questions