Guest User

Untitled

a guest
Jul 11th, 2018
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. ##
  2. #!/usr/bin/ruby
  3.  
  4. require 'rubygems'
  5. require 'fastercsv'
  6. require 'activerecord'
  7.  
  8. ActiveRecord::Base.establish_connection(
  9. :adapter => "mysql",
  10. :host => "192.168.0.2",
  11. :username => "root",
  12. :password => "",
  13. :database => "callcard_development"
  14. )
  15.  
  16. class Destination < ActiveRecord::Base
  17. end
  18.  
  19. FasterCSV.foreach('outbound_rates.csv') do |row|
  20. destination = Destination.new(:country => row[0], :prefix => row[1], :rate => row[4])
  21. destination.save
  22. end
  23.  
  24. ##
  25.  
  26. [diego@myhost callcard]$ time ruby rate.rb
  27.  
  28. real 1m24.715s
  29. user 0m14.869s
  30. sys 0m2.593s
  31. [diego@myhost callcard]$
Add Comment
Please, Sign In to add comment