Integrating Microsoft Access and R on MacOS

91 views Asked by At

I am working on a project where we want to pull data right from a Microsoft Access File. I figured out a way to make it work on Windows, but am running into problems on Mac (it says I don't have the right drivers). I know that Access is not supported for Mac, but I was wondering if there is still a way to pull the data directly without opening the Access file itself.

The successful windows code (just pulling a random table from the Access database)

#install.packages("odbc") 
#install.packages("RODBC")
#install.packages("tidyverse")

library(odbc)
library(RODBC)
library(tidyverse)

unique(odbc::odbcListDrivers()[[1]]) #See drivers already installed on computer
#[2] "Microsoft Access Driver (*.mdb, *.accdb)"  We have this as one of the drivers.

#Now provide the path for the database.
db <- "C:\\Users\\Molly\\Desktop\\Obleo Docs\\Data\\NPRI_20230330.accdb"


#Use RODB functions to connect db to R
#I am using the Access 2007 function, because this is the version I have
con <- RODBC::odbcConnectAccess2007(db)
print(con)

#Grab a table from the access database
df_Company <- RODBC::sqlFetch(con,"Company",rownames= FALSE)
#head(df_Company)
#View(df_Company)
#The upload worked

The unsuccessful code for Mac

library(odbc)
library(RODBC)
library(tidyverse)

unique(odbc::odbcListDrivers()[[1]]) #See drivers already installed on computer
#On a mac I got character(0). We don't have the correct drivers at this point
0

There are 0 answers