Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

more mysql drivel

2 views
Skip to first unread message

Paul Vudmaska

unread,
May 22, 2004, 3:13:42 AM5/22/04
to
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<br/>", res.num_rows
res.each do |row|
printf "%s, %s\n<br/>", 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 + '<p/>' + $@.join('<br/>')

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


Andreas Schwarz

unread,
May 22, 2004, 7:03:44 AM5/22/04
to
Paul Vudmaska wrote:
> so if you are not interested delete please.

Please stop starting a new thread with every message.

--
http://www.mikrocontroller.net - Das Mikrocontroller-Forum

Paul Vudmaska

unread,
May 22, 2004, 2:00:41 PM5/22/04
to
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.

paul vudmaska

unread,
May 23, 2004, 3:52:42 AM5/23/04
to
Paul Vudmaska <pa...@vudmaska.com> wrote in message news:<40AF9541...@vudmaska.com>...

This is definately a bad install of mysql-ruby. I've tried it with
params all ways from sunday, as per this page ,
http://www.tmtm.org/en/mysql/ruby/README. . I've written the owner. I
asked a guy who had experienced this before.
http://groups.google.com/groups?q=null+pointer+mysql-ruby&hl=en&lr=&ie=UTF-8&selm=1064375532.9480.6.camel%40localhost.localdomain&rnum=2

Yet I cant get the test.rb to fly.

The defaults dont reflect my installation so i've given the paths to
mysql, which is /usr/local/mysql. So i've changed the paths. And even
used the last option to configure from the configure command with the
same result.


[root@iis mysql-ruby-2.4.5]# ruby -I. ./test.rb localhost root pwd
connect.............ok
create_db...........ok
create_table........ok
insert..............ok
select.............../t/40select.rb:4:in `fetch_hash': NULL pointer
given (Arg
entError)
from ./t/40select.rb:4
from ./test.rb:23:in `load'
from ./test.rb:23
from ./test.rb:19:in `each'
from ./test.rb:19

[root@iis mysql-ruby-2.4.5]# ruby extconf.rb --with-mysql-config
checking for mysql.h... yes
creating Makefile
[root@iis mysql-ruby-2.4.5]# make
gcc -fPIC -g -O2 -I. -I/usr/local/lib/ruby/1.8/i686-linux
-I/usr/local/lib/ruby/1.8/i686-linux -I. -DHAVE_MYSQL_H
-I/usr/local/mysql/include -mcpu=pentiumpro -c mysql.c
gcc -shared -L"/usr/local/lib" -o mysql.so mysql.o
-L/usr/local/mysql/lib -lmysqlclient -lz -lcrypt -lnsl -lm -lc
-lnss_files -lnss_dns -lresolv -lc -lnss_files -lnss_dns -lresolv
-ldl -lcrypt -lm -lc
[root@iis mysql-ruby-2.4.5]# ruby -I. ./test.rb localhost root pwd
connect.............ok
create_db...........ok
create_table........ok
insert..............ok
select.............../t/40select.rb:4:in `fetch_hash': NULL pointer
given (ArgumentError)
from ./t/40select.rb:4
from ./test.rb:23:in `load'
from ./test.rb:23
from ./test.rb:19:in `each'
from ./test.rb:19
[root@iis mysql-ruby-2.4.5]# ruby extconf.rb
--with-mysql-config=/usr/local/mysql/config
extconf.rb:1: command not found: /usr/local/mysql/config --cflags
[root@iis mysql-ruby-2.4.5]# ruby extconf.rb
--with-mysql-include=/usr/local/mysql/include
--with-mysql-lib=/usr/local/mysql/lib
--with-mysql-dir=/usr/local/mysql
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lm... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lz... yes
checking for mysql_query() in -lmysqlclient... yes
checking for mysql.h... yes
creating Makefile
[root@iis mysql-ruby-2.4.5]# make
gcc -fPIC -g -O2 -I. -I/usr/local/lib/ruby/1.8/i686-linux
-I/usr/local/lib/ruby/1.8/i686-linux -I. -DHAVE_MYSQL_H
-I/usr/local/mysql/include -I/usr/local/mysql/include -c mysql.c
gcc -shared -L"/usr/local/lib" -L"/usr/local/mysql/lib" -o mysql.so
mysql.o -lmysqlclient -lz -lm -ldl -lcrypt -lm -lc
[root@iis mysql-ruby-2.4.5]# ruby -I. ./test.rb localhost root pwd
connect.............ok
create_db...........ok
create_table........ok
insert..............ok
select.............../t/40select.rb:4:in `fetch_hash': NULL pointer
given (ArgumentError)
from ./t/40select.rb:4
from ./test.rb:23:in `load'
from ./test.rb:23
from ./test.rb:19:in `each'
from ./test.rb:19
[root@iis mysql-ruby-2.4.5]#

I've tried above and more. I dont know where these libraries are or
even what it asking for.

any insight besides 'dont top post' would be great.

Michael Neumann

unread,
May 23, 2004, 7:13:51 AM5/23/04
to
On Sun, May 23, 2004 at 04:53:45PM +0900, paul vudmaska wrote:
> Paul Vudmaska <pa...@vudmaska.com> wrote in message news:<40AF9541...@vudmaska.com>...
> > 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.
>
> This is definately a bad install of mysql-ruby. I've tried it with

Does this mean (which I except) that it's not a bug in DBI? If the same
error occurs with and without DBI, then it's probably not a DBI related
bug.

I am a bit confused about mysql-ruby and ruby-mysql. I know that one of
them in a pure Ruby library and the other is a C library. Does the error
occurs in both?


Regards,

Michael


Rich

unread,
May 23, 2004, 10:51:18 AM5/23/04
to
Use ruyb-mysql and don't use dbi.

I've been down what sounds like the same frustrating road, and it didn't
stop until I used ruby-mysql.

(Note: ruby-mysql is different from mysql-ruby)

-Rich

Paul Vudmaska

unread,
May 23, 2004, 2:42:55 PM5/23/04
to
Michael Neumann wrote:

Thanks for taking the time to answer, Michael

I dont think it is DBI. Next to certain it is mysql-ruby. It does not
pass the installation test. My host installed everything so it has been
a struggle to figure that out .

I did try to install ruby-mysql- and i get an error during install.
(LoadError ) socket. I would not have relieved much pain anyway.

I did hear from Tomita - author of the ruby-mysql and mysql-ruby...

>>I'm sorry, I don't know why this error occured.

I tried following environment, but it worked fine.

Debian
Ruby 1.8.1
MySQL/Ruby 2.4.5
MySQL 4.0.17

Please try to upgrade Ruby or MySQL.
<<

I guess i could try that except the differences on the dedicated box i use is Redhat and MySQL is already a newer version. My host refuses to touch anything else "we've tried" and i cant blame them - even tho i'd like too :)

Now, i'm caught in a conundrum. If i can not get mysql(w/dbi) to work - i'll have to go with postegres which i used
for awhile on my other host, with a few mods. So i'll need to figure out a way to get the data from mysql to postgres and install it on the machine- along with the dbi -dbd for postgres. I'm having a little trouble getting excited about it.

You know, i stuck with the dbi because i think it is more elegant than the rest - not so i could change dbs sometime down the road. Lucky me!

I'm pretty wiped out and wistfully looking to the days of asp M$ - which my biz partner loudly suggested i stick to for this, fairly big, project - about 10 sites with content mgt. It's crow on the menu for me!


Stick a fork in me

Paul


Detlef Reichl

unread,
May 23, 2004, 3:10:57 PM5/23/04
to
On Mon, 2004-05-24 at 03:42 +0900, Paul Vudmaska wrote:

> I dont think it is DBI. Next to certain it is mysql-ruby. It does not
> pass the installation test. My host installed everything so it has been
> a struggle to figure that out .
>
> I did try to install ruby-mysql- and i get an error during install.
> (LoadError ) socket. I would not have relieved much pain anyway.
>

i've got the same problems on debian with the mysql-ruby packages. for
me it helped to install 'em from source.

cheers
detlef


--
Wer für alles offen ist, kann nicht ganz dicht sein.

<* ))))x<

Paul Vudmaska

unread,
May 23, 2004, 4:15:08 PM5/23/04
to
Detlef Reichl wrote:

>On Mon, 2004-05-24 at 03:42 +0900, Paul Vudmaska wrote:
>
>
>
>>I dont think it is DBI. Next to certain it is mysql-ruby. It does not
>>pass the installation test. My host installed everything so it has been
>>a struggle to figure that out .
>>
>>I did try to install ruby-mysql- and i get an error during install.
>>(LoadError ) socket. I would not have relieved much pain anyway.
>>
>>
>>
>
>i've got the same problems on debian with the mysql-ruby packages. for
>me it helped to install 'em from source.
>
>cheers
>detlef
>
>
>
>

i thot i was installing from source =) , which may tell you something.
I may consider that sometime down the road once i get my head above
water. Thank you, though.

:Paul


0 new messages