Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env ruby
- require "dbi"
- require "date"
- begin
- # Connect to the MySQL server
- dbh = DBI.connect("dbi:Mysql:tracking:sfpmysql01","root","1force1")
- update_statement = dbh.prepare("INSERT INTO tbl_tracking_pixel (MEMBER_ID, ESRC, ISRC, PLOC, VISITOR_ID, PAGE_ID, created_date) VALUES (?,?,?,?,?,?,?)")
- if File.exist?("/mgr/tmp/pixeldata/VerifyUser.log")
- file = File.new("/mgr/tmp/pixeldata/VerifyUser.log", "r")
- file.readlines.each {|line|
- line_array = line.split(" ")
- created_date = line_array[3].to_s + '-' + '04' + '-' + line_array[2].to_s + ' ' + line_array[4].to_s + ':00'
- opts_array = line_array[6].split("~~")
- member_id = opts_array[1]
- esrc = opts_array[2]
- isrc = opts_array[3]
- ploc = opts_array[4]
- visitor_id = opts_array[5]
- page_id = opts_array[6]
- update_statement.execute(member_id, esrc, isrc, ploc, visitor_id, page_id, created_date);
- }
- update_statement.finish;
- file.close
- else
- puts "File not found!"
- end
- dbh.finish
- puts "Ok, your work is done here Jason. Coffee?"
- # In case things go wrong, catch it and post the error.
- rescue DBI::DatabaseError => dberr
- puts "An error occured"
- puts "Error code: #{dberr.err}"
- puts "Error messages: #{dberr.errstr}"
- # In case things go wrong, be sure to close the database connection.
- ensure
- # Disconnect from server
- dbh.disconnect if dbh
- end
Add Comment
Please, Sign In to add comment