cdr_pull_db_tbls: Collect both tables (admin & chg-log) from the DB, join them...

View source: R/cdr_pull_db_tbls.R

cdr_pull_db_tblsR Documentation

Collect both tables (admin & chg-log) from the DB, join them in a user view, and return all 3 tables in a list

Description

Collect both tables (admin & chg-log) from the DB, join them in a user view, and return all 3 tables in a list

Usage

cdr_pull_db_tbls(
  conn_pool,
  db_tbl_name,
  chg_log_suffix = "_DELTAS",
  key_field = "UID",
  ...
)

Arguments

conn_pool

connection object (preferably a pool::dbPool() connection)

db_tbl_name

name of your primary table

chg_log_suffix

name of your change-log table suffix

key_field

column in the primary table that acts as the unique row identifier

...

other database pointer params like schema

Value

a list with primary (admin), change-log, and end-user view tables as list elements

Examples

## Not run: 
con <- DBI::dbConnect(
  drv = RPostgres::Postgres(),
  dbname = "test",
  host = "localhost",
  user = Sys.getenv('postgres_username'),
  password = Sys.getenv('postgres_password')
  )

as_of <- lubridate::now()-lubridate::years(1)
DBI::dbListTables(con)
DBI::dbListObjects(con)
# both_tbls <- cdr_pull_db_tbls(con, db_tbl_name = 'iris', key_field = 'UID', schema = "test")
DBI::dbDisconnect(con)

## End(Not run)


eauleaf/crudr documentation built on Jan. 29, 2024, 4:39 p.m.