Description Usage Arguments Value Examples
View source: R/OutputDatabase.R
Update values of dbOutput based on a new database
1 2 3 4 5 6 7 | dbOut_update_values(
dbOut_fname,
dbNew_fname,
fields_update = NULL,
fields_exclude = NULL,
verbose = FALSE
)
|
dbOut_fname |
A character string. The file path of the main
|
dbNew_fname |
A character string. The file path of a database with
new values that are used to update corresponding values in
|
fields_update |
A named list of vectors with character strings. The
field names per table to be updated. Each table is represented by a
correspondingly named element. If |
fields_exclude |
A named list of vectors with character strings. The
field names per table to be updated. Each table is represented by a
correspondingly named element. If |
verbose |
A logical value. |
Invisibly, the name of a new table that tracks which records
(identified by P_id
) have been updated (value 1) for each
table.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | ## Not run:
if (requireNamespace("RSQLite") && exists("SFSW2_prj_meta")) {
table <- dbOut_update_values(
dbOut_fname = SFSW2_prj_meta[["fnames_out"]][["dbOutput"]],
dbNew_fname = "path/to/new.sqlite3",
fields_exclude = list(
aggregation_overall_mean = c("MAT_C_mean", "MAP_mm_mean"),
aggregation_overall_sd = c("MAT_C_sd", "MAP_mm_sd")))
con <- RSQLite::dbConnect(RSQLite::SQLite(),
SFSW2_prj_meta[["fnames_out"]][["dbOutput"]])
fields <- RSQLite::dbQuoteIdentifier(con,
RSQLite::dbListFields(con, table))
# Extract Pids from records that were updated
sql <- paste("SELECT P_id FROM", table, "WHERE",
paste(fields[-1], "= 1", collapse = " AND "))
is_good <- RSQLite::dbGetQuery(con, sql)
RSQLite::dbDisconnect(con)
}
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.