Dbi problem

Hi.

I’m trying to make ruby dbi work. I searched around, but could not find an
answer to this, so please forgive me if you’ve heard this one before…

I get the following error when trying to run my script (with eruby, the
script is supposed to be called from an rhtml page):

/usr/lib/ruby/site_ruby/1.6/dbi/dbi.rb:434:in load_driver': Could not load driver (uninitialized constant Mysql at DBI::DBD) (DBI::InterfaceError) from /usr/lib/ruby/site_ruby/1.6/dbi/dbi.rb:349:in_get_full_driver’
from /usr/lib/ruby/site_ruby/1.6/dbi/dbi.rb:329:in connect' from ./pgmkr.rb:125:indb_connect’

The offending line is:
@dbh = DBI.connect(datasrc, usr, pwd)

This is my ruby version:
ruby 1.6.6 (2001-12-26) [i586-linux-gnu]

This file exists:
/usr/lib/ruby/site_ruby/1.6/DBD/Mysql/Mysql.rb

If I run this script (from the syngress Ruby Developer’s guide book)
DBI.available_drivers.each do |driver|
puts "Driver: " + driver
DBI.data_sources(driver).each do |dsn|
puts " Datasource: " + dsn
end
end

I get this output:
Driver: dbi:Mysql:
/usr/lib/ruby/site_ruby/1.6/dbi/dbi.rb:434:in load_driver': Could not load driver (uninitialized constant Mysql at DBI::DBD) (DBI::InterfaceError) from /usr/lib/ruby/site_ruby/1.6/dbi/dbi.rb:377:indata_sources’
from db_list.rb:7
from db_list.rb:5:in `each’
from db_list.rb:5

So, I am confused…these scripts works on my WIN machine at work…am I
doing something dumb?

I'm trying to make ruby dbi work. I searched around, but could not
find an answer to this, so please forgive me if you've heard this
one before...

I get the following error when trying to run my script (with eruby,
the script is supposed to be called from an rhtml page):

/usr/lib/ruby/site_ruby/1.6/dbi/dbi.rb:434:in `load_driver': Could not load
driver (uninitialized constant Mysql at DBI::DBD) (DBI::InterfaceError)
        from /usr/lib/ruby/site_ruby/1.6/dbi/dbi.rb:349:in
`_get_full_driver'
        from /usr/lib/ruby/site_ruby/1.6/dbi/dbi.rb:329:in `connect'
        from ./pgmkr.rb:125:in `db_connect'

The offending line is:
@dbh = DBI.connect(datasrc, usr, pwd)

This is my ruby version:
ruby 1.6.6 (2001-12-26) [i586-linux-gnu]

This file exists:
/usr/lib/ruby/site_ruby/1.6/DBD/Mysql/Mysql.rb

It looks like you have an incomplete installation of DBI. You need
the mysql bindings, and you also need the DBD interface to wrap it, so
technically you need three components. The various DBD's are often
times installed automagically for you by the DBI installation or by
the port (if you use FreeBSD), however you can't always assume that.
Once you get that fixed, I think you'll be all good to go. -sc

···

--
Sean Chittenden

Sean Chittenden thinks he wrote:

I’m trying to make ruby dbi work. I searched around, but could not
find an answer to this, so please forgive me if you’ve heard this
one before…

I get the following error when trying to run my script (with eruby,
the script is supposed to be called from an rhtml page):

/usr/lib/ruby/site_ruby/1.6/dbi/dbi.rb:434:in load_driver': Could not load driver (uninitialized constant Mysql at DBI::DBD) (DBI::InterfaceError) from /usr/lib/ruby/site_ruby/1.6/dbi/dbi.rb:349:in_get_full_driver’
from /usr/lib/ruby/site_ruby/1.6/dbi/dbi.rb:329:in connect' from ./pgmkr.rb:125:indb_connect’

The offending line is:
@dbh = DBI.connect(datasrc, usr, pwd)

This is my ruby version:
ruby 1.6.6 (2001-12-26) [i586-linux-gnu]

This file exists:
/usr/lib/ruby/site_ruby/1.6/DBD/Mysql/Mysql.rb

It looks like you have an incomplete installation of DBI. You need
the mysql bindings, and you also need the DBD interface to wrap it, so
technically you need three components. The various DBD’s are often
times installed automagically for you by the DBI installation or by
the port (if you use FreeBSD), however you can’t always assume that.
Once you get that fixed, I think you’ll be all good to go. -sc

Thanks. I got it working. If you install from the distro’s RPMs, Mandrake
8.2 puts mysql files in /usr/include and /usr/lib instead of /usr/local, so
to configure the MySQL Ruby module you have to use the
’–with-mysql-dir=/usr’ argument to extconf.rb. Then, it will work.