-
Notifications
You must be signed in to change notification settings - Fork 80
Add dbWriteTable method for the CSV #254
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Thanks! Can you comment if this approach could be a viable solution for the performance problems in RMariaDB too:
|
I think the My goal in this PR was just to reduce memory usage for more optimal ETL. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. Instead of adding yet another dbWriteTable()
method, I'd rather implement a new postgresAppendTableCSV()
that does everything minus table creation/removal. We can later decide if we add a new dbAppendTable()
method or implement a new dbAppendTableCSV()
generic.
Would you like to help with a |
Sure. Can you provide more details? I didn't find anything in this repo. |
DBI now has |
Fast draft the postgresAppendTableCSV <- function(conn, name, value, fields = NULL, sep = ",", header = TRUE, na.strings = "NA", encoding = "UTF-8") {
sql <- paste0(
"COPY ", dbQuoteIdentifier(conn, name),
" (", paste(dbQuoteIdentifier(conn, fields), collapse = ","), ") ",
"FROM STDIN ",
"(FORMAT CSV DELIMITER '", sep, "', HEADER '", header, "' NULL '", na.strings, "' ENCODING '", encoding, "')"
)
connection_copy_file(conn@ptr, sql, path.expand(value))
invisible(TRUE)
} |
To load CSV directly: