defer_db_cleanup: Delete table at function exit

View source: R/helpers.R

defer_db_cleanupR Documentation

Delete table at function exit

Description

This function marks a table for deletion once the current function exits.

Usage

defer_db_cleanup(db_table)

Arguments

db_table

(tbl_sql)
A unmanipulated reference to a sql table.

Value

NULL (called for side effects)

Examples


  conn <- get_connection()

  mt <- dplyr::copy_to(conn, mtcars)
  id_mt <- id(mt)

  defer_db_cleanup(mt)

  DBI::dbExistsTable(conn, id_mt) # TRUE

  withr::deferred_run()

  DBI::dbExistsTable(conn, id_mt) # FALSE

  close_connection(conn)


SCDB documentation built on Oct. 4, 2024, 1:09 a.m.