bulkLoad parameter causes error with DatabaseConnector::insertTable
rkboyce opened this issue · 1 comments
rkboyce commented
Hi,
I am in R 3.6.3 using ETL-Synthea (installed using install_github on 12/18) with DatabaseConnector (same installation date and method) to upload data and ran into the following error.
Error in DatabaseConnector::insertTable(conn, tableName = paste0(syntheaSchema, :
unused argument (bulkLoad = bulkLoad)
This modified function works but does not include bulkUpload - not sure if its should set the 'useMppBulkLoad' parameter.
LoadSyntheaTables <-
function(connectionDetails,
syntheaSchema,
syntheaFileLoc)
{
csvList <- list.files(syntheaFileLoc, pattern = "*.csv")
conn <- DatabaseConnector::connect(connectionDetails)
for (csv in csvList) {
syntheaTable <-
data.table::fread(
file = paste0(syntheaFileLoc,"/",csv),
stringsAsFactors = FALSE,
header = TRUE,
sep = ",",
na.strings = ""
)
writeLines(paste0("Loading: ", csv))
# experiencing type conversion errors and need to explicitly case some columns
if ("START" %in% colnames(syntheaTable))
syntheaTable$START <-
as.Date(syntheaTable$START, format = "%Y-%m-%d")
if ("STOP" %in% colnames(syntheaTable))
syntheaTable$STOP <-
as.Date(syntheaTable$STOP, format = "%Y-%m-%d")
if ("DATE" %in% colnames(syntheaTable))
syntheaTable$DATE <-
as.Date(syntheaTable$DATE, format = "%Y-%m-%d")
if ("BIRTHDATE" %in% colnames(syntheaTable))
syntheaTable$BIRTHDATE <-
as.Date(syntheaTable$BIRTHDATE, format = "%Y-%m-%d")
if ("DEATHDATE" %in% colnames(syntheaTable))
syntheaTable$DEATHDATE <-
as.Date(syntheaTable$DEATHDATE, format = "%Y-%m-%d")
if ("CODE" %in% colnames(syntheaTable))
syntheaTable$CODE <- as.character(syntheaTable$CODE)
if ("REASONCODE" %in% colnames(syntheaTable))
syntheaTable$REASONCODE <-
as.character(syntheaTable$REASONCODE)
if ("PHONE" %in% colnames(syntheaTable))
syntheaTable$PHONE <-
as.character(syntheaTable$PHONE)
if ("UTILIZATION" %in% colnames(syntheaTable))
syntheaTable$UTILIZATION <-
as.numeric(syntheaTable$UTILIZATION)
suppressWarnings({
DatabaseConnector::insertTable(
conn,
tableName = paste0(syntheaSchema, ".", strsplit(csv, "[.]")[[1]][1]),
data = as.data.frame(syntheaTable),
dropTableIfExists = FALSE,
createTable = FALSE,
progressBar = TRUE
)
})
}
on.exit(DatabaseConnector::disconnect(conn))
}