Advertisement
Guest User

Untitled

a guest
Sep 15th, 2016
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. save_data <- function(data) {
  2. # Connect to the database
  3. db <- dbConnect(MySQL(), dbname = databaseName, host =
  4. options()$mysql$host,
  5. port = options()$mysql$port, user = options()$mysql$user,
  6. password = options()$mysql$password)
  7.  
  8. # Add insertion time stamp of the record and re-order columns
  9. data <- data %>%
  10. mutate(insert_dtm = Sys.time()) %>%
  11. select (insert_dtm, everything()) %>%
  12.  
  13. # Construct the update query by looping over the data fields
  14. query <- sprintf(foo)
  15.  
  16. # Submit the update query and disconnect
  17. dbGetQuery(db, query)
  18. dbDisconnect(db)
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement