dm (version 0.0.3.9003)

cdm_copy_to: Copy a dm-object to a src/con

Description

cdm_copy_to() takes a src- or con-object as a first argument, and a dm object as a second. The latter is copied to the former. By default the key constraints will be set (for now only on MSSQL- and Postgres-DBs). By default temporary tables will be created.

Usage

cdm_copy_to(dest, dm, ..., types = NULL, overwrite = NULL,
  indexes = NULL, unique_indexes = NULL, set_key_constraints = TRUE,
  unique_table_names = FALSE, table_names = NULL, temporary = TRUE)

Arguments

dest

A src or con object like e.g. a database.

dm

A dm object.

...

Possible further arguments passed to dplyr::copy_to() (which is used on each table)

overwrite, types, indexes, unique_indexes

Must remain NULL.

set_key_constraints

Boolean variable, if TRUE will mirror dm key constraints on a database.

unique_table_names

Boolean, if FALSE (default), original table names will be used, if TRUE, unique table names will be created based on the original table names.

table_names

A named character vector, containing the names you want the tables in the dm to have after copying them to the database. The table names within the dm will remain unchanged. The name of each element of the vector needs to be one of the table names of the dm. Those tables of the dm that are not addressed will be called by their original name on the database.

temporary

Boolean variable, if TRUE will only create temporary tables, which will vanish when connection is interrupted.

Details

No tables will be overwritten, passing overwrite = TRUE gives an error. Types are determined separately for each table, setting the types argument also gives an error. The arguments are included in the signature to avoid passing them via the ... ellipsis.

See Also

Other DB interaction functions: cdm_learn_from_db

Examples

Run this code
# NOT RUN {
src_sqlite <- dplyr::src_sqlite(":memory:", create = TRUE)
iris_dm <- cdm_copy_to(
  src_sqlite,
  as_dm(list(iris = iris)),
  set_key_constraints = FALSE
)
# }

Run the code above in your browser using DataLab