Skip to contents

Takes a survey decomposed into component tables by srv_decompose_for_db() and uploads each table to its respective place in the survey database.

Usage

db_insert_survey_decomposition(con, decomposition)

Arguments

con

A DBI connection to the database, which can be established using rds_connect_to_database().

decomposition

A list of dataframes, an output of srv_decompose_for_db().

Examples

data_marked <-
  example_survey_data_climate |>
  assign_col_module("demographics", XIDEO, XPARTY7) |>
  assign_col_module("questionnaire", starts_with("Q")) |>
  assign_col_response_type("multiple_response", starts_with("Q17_Q16")) |>
  assign_col_response_type("single_response", XIDEO, XPARTY7, Q11) |>
  assign_col_mr_group("Q17_Q16", starts_with("Q17_Q16"))

decomposition <-
  srv_decompose_for_db(
    data_marked,
    respondent_id_col = response_id,
    weight_col = weight,
    survey_id = "climate",
    survey_name = "Opinions on Climate",
    date_start = as.Date("2022-10-12"),
    date_end = as.Date("2022-10-14")
  )

if (FALSE) { # \dontrun{
con <-
  rds_connect_to_database(
    database = rds_get_database("my-database-id"),
    secret = secretManager_get_secret("my-secret")
  )

db_insert_survey_decomposition(con, decomposition)

} # }