View source: R/cdr_make_db_tbls.R
cdr_make_db_tbls | R Documentation |
Writes an initial primary table into the database specified by conn_pool, as well as the corresponding deltas metadata table required for change tracking.
cdr_make_db_tbls(
conn_pool,
db_tbl,
key_field = NULL,
make_deltas_tbl = TRUE,
chg_log_suffix = "_DELTAS",
...
)
conn_pool |
a database connection of class 'pool' |
db_tbl |
a dataframe; the primary table to place into the database |
key_field |
string: a unique ID column name in the data. If NULL,
creates a key field called |
make_deltas_tbl |
set to FALSE if you only want to write a primary table without its corresponding change log table |
chg_log_suffix |
to provide a suffix other than the default '_DELTAS' when creating your database change-log table |
... |
additional table name parameters passed to |
Note: if you want to remove your table, these functions can be helpful:
pool::dbListTables(conn_pool)
pool::dbRemoveTable(conn_pool, cdr_id(table = 'some_table'))
invisibly returns NULL
## Not run:
con <- pool::dbPool(DBI::dbConnect(RSQLite::SQLite(), 'iris.db'))
cdr_make_db_tbls(con, iris)
pool::dbListTables(conn_pool)
pool::dbRemoveTable(con, 'iris')
pool::dbRemoveTable(con, 'iris_deltas')
con <- DBI::dbConnect(
RPostgres::Postgres(),
host = "localhost",
dbname = "PG_DEV",
user = Sys.getenv("postgres_username"),
password = Sys.getenv("postgres_password")
)
cdr_make_db_tbls(con, iris, schema = 'test')
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.