Advertisement
Guest User

Untitled

a guest
Jul 6th, 2017
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. library(RMySQL)
  2.  
  3. # Clean connection list
  4. all_cons <- dbListConnections(MySQL())
  5.  
  6. u <- 'sa'
  7. db <- 'my_db'
  8. p <- '******'
  9. h <- '127.0.0.1'
  10. port <- 3306
  11.  
  12. for(con in all_cons)
  13. + dbDisconnect(con)
  14. print(paste(length(all_cons), " connections killed."))
  15.  
  16. # Connect mysql
  17. dbconn_fomula = dbConnect(MySQL(), user=u, password=p, dbname=db, host=h, port=port, DBMSencoding="UTF8")
  18.  
  19. dbconn_fomula.update_fomula <- function(data_result)# metric, a,b,c,fo,fo_weight
  20. {
  21. call_sp = paste0("call update_metric_fomula('"
  22. ,data_result[1],"','" # metric
  23. ,data_result[2],"'," # language
  24. ,data_result[3],"," # a
  25. ,data_result[4],"," # b
  26. ,data_result[5],",'" # c
  27. ,data_result[6],"'," # fo
  28. ,data_result[7],");")# fo_weight
  29.  
  30. updated_rows = dbExecute(dbconn_fomula, call_sp )
  31.  
  32. return( call_sp)
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement