Most code examples showing how to use dplyr with a database include 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 the creation of the db object:
tbl <- tbl(DBI::dbConnect(odbc::odbc(), .connection_string=connStr), "mytable") tbl %>% verb1 %>% verb2 %>% ...
Are there any implications for this? Will I use database resources / memory leak / etc?
The DBMS that I mean is SQL Server, and the driver package is odbc, if that matters.
source share