dettl_auto_load: Automatic load function for append mode imports.

View source: R/automatic_load.R

dettl_auto_loadR Documentation

Automatic load function for append mode imports.

Description

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.

Usage

dettl_auto_load(transformed_data, con)

Arguments

transformed_data

The list of transformed data frames to append to tables in the database.

con

Connection to the database to add data to.

Details

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.

Examples

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)

vimc/dettl documentation built on Oct. 6, 2022, 2:13 p.m.