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.

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



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


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.


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


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


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


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


src_sqlite <- dplyr::src_sqlite(":memory:", create = TRUE) iris_dm <- cdm_copy_to( src_sqlite, as_dm(list(iris = iris)), set_key_constraints = FALSE )