copy_dm_to {dm} | R Documentation |
copy_dm_to()
takes a dplyr::src_dbi object or a DBI::DBIConnection
object as its first argument
and a dm
object as its second argument.
The latter is copied to the former.
The default is to create temporary tables, set temporary = FALSE
to create permanent tables.
Unless set_key_constraints
is FALSE
, primary key constraints are set on all databases,
and in addition foreign key constraints are set on MSSQL and Postgres databases.
copy_dm_to(
dest,
dm,
...,
types = NULL,
overwrite = NULL,
indexes = NULL,
unique_indexes = NULL,
set_key_constraints = TRUE,
unique_table_names = NULL,
table_names = NULL,
temporary = TRUE,
schema = NULL,
progress = NA,
copy_to = NULL
)
dest |
An object of class |
dm |
A |
... |
Passed on to |
overwrite, types, indexes, unique_indexes |
Must remain |
set_key_constraints |
If |
unique_table_names |
Deprecated. |
table_names |
Desired names for the tables on If left
If a function or one-sided formula, Use a variant of
If a named character vector,
the names of this vector need to correspond to the table names in the Use qualified names corresponding to your database's syntax to specify e.g. database and schema for your tables. |
temporary |
If |
schema |
Name of schema to copy the Not all DBMS are supported. |
progress |
Whether to display a progress bar, if |
copy_to |
By default, |
No tables will be overwritten; passing overwrite = TRUE
to the function will give an error.
Types are determined separately for each table, setting the types
argument will
also throw an error.
The arguments are included in the signature to avoid passing them via the
...
ellipsis.
A dm
object on the given src
with the same table names
as the input dm
.
con <- DBI::dbConnect(RSQLite::SQLite())
# Copy to temporary tables, unique table names by default:
temp_dm <- copy_dm_to(
con,
dm_nycflights13(),
set_key_constraints = FALSE
)
# Persist, explicitly specify table names:
persistent_dm <- copy_dm_to(
con,
dm_nycflights13(),
temporary = FALSE,
table_names = ~ paste0("flights_", .x)
)
dbplyr::remote_name(persistent_dm$planes)
DBI::dbDisconnect(con)