Hi all, I'm trying to connect to a postgresql db through Watir, execute a query and output the result of the query to a .csv file. I can connect, query and print (puts) to screen correctly, but am unable to put the output to the .csv file.
require 'watir' require 'postgres' conn=PGconn.connect("172.xx.xx.xx", 5432, "", "", "db_name", "root", "") res = conn.exec('select * from table_stats') out = File.new('C:\ruby\test\data.csv', 'w') res.each do |row| row.each do |column| print column end out.puts end __________________________________________________________ Following is the code I use to just print on screen: res = conn.exec("select * from table_stats") res.each do |row| row.each do |column| print column (20-column.length).times{print " "} end puts end __________________________________________________________ Alternatively, I tried to use fetch() method, but I get an error saying it is an undefined method. Any suggestions? Thanks! --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Watir General" group. To post to this group, send email to watir-general@googlegroups.com Before posting, please read the following guidelines: http://wiki.openqa.org/display/WTR/Support To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/watir-general -~----------~----~----~----~------~----~------~--~---