dettl_auto_load.Rd
The automatic load function loops over the transformed data and appends each data frame to the matching table in the database. If the appended table contains a key referenced by one of the foreign key constraints then when the data is inserted into the database this returns the value of the key for the new rows. Then loop over all tables in which this is used as a foreign key and update the previous values to use the returned actual values for the referenced key.
dettl_auto_load(transformed_data, con)
The list of transformed data frames to append to tables in the database.
Connection to the database to add data to.
Expect that this should only be called from within a custom load function if we want to load data to the database in the automatic way but have some special edge cases which we need to add some custom handling for before or after running the automatic load.
path <- dettl:::prepare_test_import(
system.file("examples", "person_information", package = "dettl"),
system.file("examples", "dettl_config.yml", package = "dettl")
)
import <- dettl::dettl(file.path(path, "person_information"), "test")
con <- import$get_connection()
data <- list("people" = data.frame(
name = c("Alice", "Bob"),
age = c(25, 43),
height = c(175, 187),
stringsAsFactors = FALSE))
dettl_auto_load(data, con)
#> Updating people (adding 2 rows)