From: beny 18241 Date: 2009-12-20T06:05:44+09:00 Subject: How to put File lines into postgres query(pg) Hi, I have a script which parsing some xml files(works great :)) ----- File.open(file).each do |line| if line =~ //..line =~ /<\/prf:CcppAccept>/ if line =~ /(image|audio|video).*<\/rdf:li>/ line.gsub( 'image/bmp', "INSERT INTO table VALUES(\'#{dev_name}\',\'bmpinpage\',\'true\')").gsub( 'audio/mp3', "INSERT INTO table VALUES(\'#{dev_name}\',\'downloadable.audio.MP3\')").gsub( 'video/mp4',"INSERT INTO table VALUES(\'#{dev_name}\',\'downloadable.video.MP4\')").gsub( "<\/rdf:li>", ";").each do |ss| print ss end end end end ---- but now I wanted to put this regexped lines into postgres queries def query1 conn = PGconn.new({:host=>'localhost',:user=>'postgres',:dbname=>'data'}) res = conn.exec('#{ss}') res.each do |row| row.each do |column| print column end puts end but its not working, please can anybody tell how to push this lines into this postgres querries ?? Regards beny18241 -- Posted via http://www.ruby-forum.com/.