R: No applicable method for 'tbl' error when making a SQL Server query using dplyr and pool
library(RJDBC) library(DBI) library(pool) library(dplyr) drv <- JDBC( "com.microsoft.sqlserver.jdbc.SQLServerDriver", "C:/R/RJDBC/Microsoft JDBC Driver 6.0 for SQL Server/sqljdbc_6.0/enu/jre8/sqljdbc42.jar" ) pool_instance <- dbPool( drv = drv, dbname = "dbasename", url = "jdbc:sqlserver://sql01", user = "user", password = "password" ) mydata <- dbGetQuery(pool_instance, "select * from my.Table") src_pool(pool_instance) %>% tbl("my.Table") %>% head(5)
When I run this code, I make a successful connection to my SQL Server database and the
dbGetQuery function call retrieves the data as expected.
However, when I call the
src_pool function I get the following error message:
Error in UseMethod(“tbl”) : no applicable method for ‘tbl’ applied
to an object of class “c(‘src_’, ‘src_sql’, ‘src’)”
If I call the function
src_pool(pool_instance) separately, without piping to the tbl function, the error message is similar:
Error in UseMethod(“src_desc”) : no applicable method for
‘src_desc’ applied to an object of class “c(‘src_’, ‘src_sql’, ‘src’)”
I expected that either dplyr or pool would provide for these methods? Do I need to write code for these methods? What am I missing?
Note that I am a newby to SQL Server database connectivity.