Advertisement
Guest User

Untitled

a guest
Jul 20th, 2016
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. creds <- read_credentials('../cred/bi.3bpo.com')
  2. db_bi <- src_mysql( host = 'bi.3bpo.com', dbname = 'bu_adv_sem'
  3. , user = creds$user
  4. , password = creds$password)
  5.  
  6. tbl_cpl_max <- tbl(src = db_bi, 'cpl_max_archive')
  7.  
  8. tbl_cpl_max <- filter(tbl_cpl_max, channel == 'SEM' & Day >= '2016-01-01')
  9.  
  10. tbl_cpl_max <- select( tbl_cpl_max
  11. , channel
  12. , cplmax = cpl_max
  13. , product_group_name = product_group
  14. , country_iso2 = country
  15. , aid
  16. , cplmax_date = Day)
  17.  
  18. DT_cpl_max <- as.data.table(collect(tbl_cpl_max))
  19.  
  20. DT_cpl_max[, `:=`(channel = NULL, aid = NULL)]
  21.  
  22.  
  23. db_zolv <- open_channel(host_name, credentials_path, db_name = 'semai')
  24. dbWriteTable( db_zolv, name = 'exchange_cplmax', value = DT_cpl_max
  25. , append = TRUE
  26. , row.names = FALSE)
  27.  
  28. disconnect_all_MySQL()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement