Skip to contents

Removes a specified table by deleting the table or by removing just the table data (truncating)

Usage

cdr_trunc_tbl(
  conn_pool,
  db_tbl_name = NULL,
  removal = c("truncate", "delete"),
  ...
)

Arguments

conn_pool

pool connection object: the pool of connections established by the session

db_tbl_name

string: name of the specific table, or cdr_id() object

removal

string: one of 'truncate' or 'delete'

...

other args specifying a DB table such as schema = 'my_schema'

Value

TRUE for success; FALSE for removal fail

Examples

if (FALSE) {

con <- pool::dbPool(DBI::dbConnect(RSQLite::SQLite(), 'test.db'))
example_tbl <- dplyr::mutate(iris, bool = Species == 'setosa', day = Sys.Date(), test = Sys.time())
cdr_make_db_tbls(con, example_tbl, chg_log_suffix = '_deltas')
con |> DBI::dbListTables()
cdr_trunc_tbl(conn_pool = con, db_tbl_name = 'example_tbl', removal = 'truncate')
con |> DBI::dbListTables()
DBI::dbListTables(con) |> purrr::map(\(.) cdr_trunc_tbl(con, ., 'delete'))
con |> DBI::dbListTables()
pool::poolClose(con)

}