From: Paul Vudmaska Date: 2004-05-23T03:00:41+09:00 Subject: mysql-ruby / dbi [was more mysql drivel] Appologies for top posting and inconveniencing everyone. redhat linux 9.2 ruby 1.8 mysql-ruby 2.4.5 dbi 0.23 mysql 4.0.2 In a nutshell, dbi is dieing(killing the response) calling either select_one, or select_all (but do works), no header, no response at all. . Using mysql-ruby i get a Null pointer error calling hashes. For example. res.each_hash do |row| #NULL Pointer given error even though res is a valid rowset, i get a null pointer. Perhaps the 2 could be related? Paul Vudmaska Paul Vudmaska wrote: > so if you are not interested delete please. > > i'm sitting contemplating my options, checking out mysql-ruby or going > back to waiting tables. The abstraction(of dbi) is not important really. > > So i start messing with mysql-ruby... > > Check this file out... > > begin > require "mysql" > require 'cgi' > cgi = CGI.new > cgi.header('content-type'=>'text/html') > sql = "SELECT * from tewt" > m = Mysql.new('localhost', 'me', 'pwd,'dev') > res = m.query(sql) > printf "%d rows were returned\n
", res.num_rows > res.each do |row| > printf "%s, %s\n
", row[0], row[1] > end > res.free > res = m.query(sql) > printf "%d rows were returned\n", res.num_rows > #dies here, Null Pointer given > res.each_hash do |row| > printf "%s, %s\n", row["id"], row["df"] > end > res.free > rescue Exception > > puts $!.to_s + '

' + $@.join('
') > > ensure > m.close > end > > ------------- > > here is the output > > 2 rows were returned > 1, 1 > 2, 2 > 2 rows were returned NULL pointer given > > /www/mytinerary/mysql.rbx:30:in `each_hash' > /www/mytinerary/mysql.rbx:30 > /usr/local/lib/ruby/1.8/apache/ruby-run.rb:53:in `load' > /usr/local/lib/ruby/1.8/apache/ruby-run.rb:53:in `handler' > > So it seems hashes might be a problem? As per this thread.... > http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/82892 > > Perhaps the same problem, as accessed through dbi causes this to hang, > me thinks, hopes > > Anyone find out if that was a bug - or am i doing something else > wrong.... > > Meanwhile, i think i'll check out ruby on rails...seems cool. > > > peace,paul > > >