The function performs some extra configuration to improve robustness.
upload_sqls_odbc(
d,
schema_name,
table_name,
dsn_name,
clear_table = FALSE,
create_table = FALSE,
convert_logical_to_integer = FALSE,
timezone = "UTC",
timezone_out = "UTC",
transaction = FALSE,
verbose = TRUE,
verbose_detail = FALSE
)
Dataset to be uploaded to the dataset. The object must inherit from data.frame
.
Name of the database destination table.
Name of the database destination table.
Name of the locally-defined DSN passed to DBI::dbConnect()
.
If TRUE
, calls deletes or truncates all records before writing to the table.
If the table structure has not yet been defined in the database, it will be created if create_table
is TRUE
.
Convert all logical
columns to integer
. This helps the database store the values as bits.
The server time zone. Passed to DBI::dbConnect()
.
The time zone returned to R. Passed to DBI::dbConnect()
. See https://www.tidyverse.org/blog/2019/12/odbc-1-2-0/.
Should the clear and upload steps be wrapped in a rollback transaction?
Display messages about the status of an upload.
Display a message about the connection's low-level details.
A boolean value that was returned by DBI::dbWriteTable()
.
If transaction
is TRUE
and the upload fails, the table is rolled back to the state before function was called.
This includes rolling back the (optional) clearing of records, and uploading the new records.
Decide if it's more robust to rollback to the previous state, or if it's better to leave the table in the incomplete state.
The latter is helpful diagnosing which record caused the write to fail; look at the last successful record contained in the database
if (FALSE) { # \dontrun{
requireNamespace("OuhscMunge")
OuhscMunge::upload_sqls_odbc(
d = ds_client, # Some data.frame that exists in RAM
schema_name = "dbo",
table_name = "tbl_client",
dsn_name = "miechv_eval",
create_table = FALSE,
clear_table = TRUE,
transaction = TRUE,
verbose = TRUE,
convert_logical_to_integer = TRUE,
timezone = "America/Chicago",
timezone_out = "America/Chicago"
)
} # }