I used to have a R code working fine a few months back, which was connecting remotely to a SQL DB and interacting with it via dbplyr package. Recently, I had to reinstall R/RStudio with all packages. Since then, I am no longer able to execute my script properly.
I am getting the following error when connecting:
Error in UseMethod("odbcListObjects") :
no applicable method for 'odbcListObjects' applied to an object of class "Microsoft SQL Server"
Meanwhile, it seems to partially work, as I am able for instance to list via DBI::dbListTables()
, but I am no longer able to interact via dplyr::tbl()
.
My problem appears similar to this SO issue rstudio dbi odbc connect Driver for SQL Server but installing the dev version of odbc or reverting to DBI 1.1.3 & odbc 1.4.1 did not work. I unfortunately don't know what package versions I had at the time.
Anyone has an idea of what may have changed within last 1,5 years regarding this packages which could explain such behavior/error?
Replicate of my code:
con2 <- DBI::dbConnect(odbc::odbc(),
driver = "SQL Driver",
server = "my_server.com",
database = "my_db",
encoding = "latin1"
)
tbl(con2, in_schema("schema", "table"))
Solution found by @Simon Couch ; however answering my own question as it could help others, awaiting for Simon to do his own:
Installing the dev version of odbc indeed fixed the problem: it is required to restart R after installing the packages.