From: Ted Date: 2002-11-19T08:08:24+09:00 Subject: Re: ruby.dbi Thanks everyone for the help. Here's what finally worked -- and it's a LOT more "Ruby-ish" than any prior attempts. Am I "getting it", or what? The query initialization puts the Ruby file name and line number, plus the SQL file's name and size as a comment to PgSQL. 1 #!/usr/bin/env ruby 2 require 'dbi' 3 begin 4 DBI.connect('DBI:pg:DeMolay','ted','yupFan') {|dbh| 5 ARGV.each{|file| 6 query = '/* '+$0+':'+__LINE__.to_s+'('+file+ 7 '['+File.size(file).to_s+"]) */\n" 8 File.open(file) {|f| query << f.readlines.to_s} 9 puts query 10 dbh.select_all(query) {|row| 11 row.each {|col| print "\t"+col.to_s} 12 puts 13 } 14 } 15 } 16 rescue => errmsg 17 puts errmsg.to_s 18 puts errmsg.backtrace 19 end