Data Access Object {#data-access-object}

Import

The section uses the following packages:

pkgs_names <- sort(c("DBI", "dbplyr", "RSQLite"))
install_string <- bookdown$print_install.packages_command(pkgs_names)
bookdown$print_package_info_table(pkgs_names)

You can install them all at once by running:


There are three important functions:

dbConnect <- DBI::dbConnect
dbWriteTable <- DBI::dbWriteTable
dbDisconnect <- DBI::dbDisconnect

Using generate_synthetic_data from chapter 4

set.seed(2020)
conn <- dbConnect(drv = RSQLite::SQLite(), path = ":memory:")
dbWriteTable(conn, name = "train_set", value = generate_synthetic_data(n = 100))
dbWriteTable(conn, name = "test_set", value = generate_synthetic_data(n = 1000))


Kiwi-Random-House/R-Projects documentation built on Dec. 31, 2020, 2:10 p.m.