Most code examples showing how to use dplyr with a database involve creating a database connection object:
connStr <- "driver=driver;server=hostname;database=mydatabase;..."
db <- DBI::dbConnect(odbc::odbc(), .connection_string=connStr)
tbl <- tbl(db, "mytable")
tbl %>% verb1 %>% verb2 %>% ...
However, suppose I omit creating a db
object:
tbl <- tbl(DBI::dbConnect(odbc::odbc(), .connection_string=connStr), "mytable")
tbl %>% verb1 %>% verb2 %>% ...
Are there any consequences to this? Will I use up database resources/leak memory/etc?
The DBMS I have in mind is SQL Server, and the driver package is odbc, in case it matters.