DBMS Connections which disconnect themselves.
Connections to Database Management Systems which automatically disconnect. In
particular connections which are created with DBI::dbConnect()
and closed
with DBI::dbDisconnect()
.
with_db_connection(con, code) local_db_connection(con, .local_envir = parent.frame())
con |
For |
code |
|
.local_envir |
|
[any]
The results of the evaluation of the code
argument.
withr
for examples
db <- tempfile() with_db_connection( list(con = DBI::dbConnect(RSQLite::SQLite(), db)), { DBI::dbWriteTable(con, "mtcars", mtcars) }) head_db_table <- function(...) { con <- local_db_connection(DBI::dbConnect(RSQLite::SQLite(), db)) head(DBI::dbReadTable(con, "mtcars"), ...) } head_db_table() unlink(db)
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.