Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/ruby
- require 'mysql2'
- gp_idx_list = []
- @last_datas = Hash.new
- @all_datas = Hash.new
- begin
- client = Mysql2::Client.new(
- :host => "localhost",
- :username => "root",
- :password => '',
- :database => 'new_pms')
- results = client.query("select distinct gp_idx from pms_data_2018")
- results.each do |row|
- gp_idx_list.push(row["gp_idx"])
- end
- results = client.query("select * from pms_data_2018 order by gp_idx, move_date")
- results.each do |row|
- @all_datas[row["idx"].to_s] = row
- @last_datas[row["gp_idx"].to_s] = row
- end
- all_datas.each do |item|
- puts item
- # if item["gp_idx"]
- # last_item = last_datas[item["gp_idx"]]
- # period_year_in_Jeju = last_item["age"] - item["age"]
- # item["period_year_in_Jeju"] = period_year_in_Jeju
- # all_datas[item["idx"]] = item
- # end
- end
- # puts all_datas
- rescue Mysql2::Error => e
- puts e.errno
- puts e.error
- ensure
- client.close if client
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement