sqlでファイル内容とデータベースで相違があるデータの挿入
require 'rubygems' require 'sqlite3' db=SQLite3::Database.new("syoku.sqlite3") f=open("food_list.txt","r"); k=0; f.each{|i| i.chomp! db.execute("insert into tmp_flg (id,flg) values (#{k},1)") d=db.execute("select * from food_list_tmp where id=#{k}") if not (d[0][1]==i) then puts d[0][1]+","+i db.execute("update food_list_tmp set foodname=\"#{i}\" where id=#{k}") db.execute("update food_list_tmp set last_update=\"2014-10-07\" where id=#{k}") db.execute("update food_list_tmp set status=\"F\" where id=#{k}") db.execute("update tmp_flg set flg=0 where id=#{k}") end k=k+1 }