Skip to content

Commit

Permalink
Postgres bulk load when using connection string parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
azimov authored Oct 4, 2024
1 parent b84f2d9 commit 9c000da
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion R/BulkLoad.R
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,19 @@ bulkLoadPostgres <- function(connection, sqlTableName, sqlFieldNames, sqlDataTyp
readr::write_excel_csv(data, csvFileName, na = "")
on.exit(unlink(csvFileName))

hostServerDb <- strsplit(attr(connection, "server")(), "/")[[1]]
server <- attr(connection, "server")()
if (is.null(server)) {
# taken directly from DatabaseConnector R/RStudio.R - getServer.default, could an attr too?
databaseMetaData <- rJava::.jcall(
connection@jConnection,
"Ljava/sql/DatabaseMetaData;",
"getMetaData"
)
server <- rJava::.jcall(databaseMetaData, "Ljava/lang/String;", "getURL")
server <- strsplit(server, "//")[[2]]
}

hostServerDb <- strsplit(server, "/")[[1]]
port <- attr(connection, "port")()
user <- attr(connection, "user")()
password <- attr(connection, "password")()
Expand Down

0 comments on commit 9c000da

Please sign in to comment.