tests/testthat/helper-with_table.R

#' Run an expression that creates and touches a table, then clean up.
#'
#' @param con PqConnection. The database connection.
#' @param tbl character. The table name.
#' @param expr expression. The R expression to execute.
#' @return the return value of the \code{expr}.
with_table <- function(con, tbl, expr) {
  on.exit(DBI::dbRemoveTable(con, tbl), add = TRUE)
  force(expr)
}

Try the RPostgres package in your browser

Any scripts or data that you put into this service are public.

RPostgres documentation built on Oct. 23, 2023, 1:06 a.m.