How to install Ruby DBI module?

I downloaded the mysql-ruby-2.8pre4, which I guess is the database
driver, and dbi-0.2.0. I have the folders, but I have no clue where to
go from here… all the websites I look at say type this command:
% ruby extconf.rb
But where do I type this? And do I type it exactly as is?

Thanks!

Ok, I typed it into the window’s command prompt, but i get this error:
\mysql-ruby-2.8pre4\extconf.rb --with-mysql-dir

*** /extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers. Check the mkmf.log file for more details. …

On Tuesday 01 July 2008, Justin To wrote:

Ok, I typed it into the window’s command prompt, but i get this error:
\mysql-ruby-2.8pre4\extconf.rb --with-mysql-dir

*** /extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers. Check the mkmf.log file for more details. …

Have you looked at the mkmf.log file? What does it say?

Stefano

mkmf.log file:

have_library: checking for main() in libmysql.lib…
-------------------- no

“cl -nologo -Feconftest -I. -Ic:/ruby/lib/ruby/1.8/i386-mswin32
-IC:/ruby/lib/ruby/gems/1.8/gems/mysql-ruby-2.8pre4
-Ic:/ruby/lib/ruby/1.8/i386-mswin32 -MD -Zi -O2b2xg- -G6 conftest.c
msvcrt-ruby18-static.lib libmysql.lib oldnames.lib user32.lib
advapi32.lib ws2_32.lib -link -libpath:”." -libpath:“c:/ruby/lib”
-stack:0x2000000"
checked program was:
/* begin /
1: #define WIN32_LEAN_AND_MEAN
2: #include <winsock2.h>
3: #include <windows.h>
4:
5: /top/
6: int main() { return 0; }
7: int t() { void ((volatile p)()); p = (void (()()))main; return 0; }
/
end */

“cl -nologo -Feconftest -I. -Ic:/ruby/lib/ruby/1.8/i386-mswin32
-IC:/ruby/lib/ruby/gems/1.8/gems/mysql-ruby-2.8pre4
-Ic:/ruby/lib/ruby/1.8/i386-mswin32 -MD -Zi -O2b2xg- -G6 conftest.c
msvcrt-ruby18-static.lib libmysql.lib oldnames.lib user32.lib
advapi32.lib ws2_32.lib -link -libpath:”." -libpath:“c:/ruby/lib”
-stack:0x2000000"
checked program was:
/* begin /
1: /top/
2: int main() { return 0; }
3: int t() { main(); return 0; }
/
end */


Also, when I try to perform the steps for setting up DBI …

ruby setup.rb config --with=dbi,dbd_mysql
=>entering config phase…
=>config done.

ruby setup.rb setup
=>no such package or diretory ‘dbi’
=>try “ruby setup.rb --help” for usage

Justin To wrote:

Also, when I try to perform the steps for setting up DBI …

ruby setup.rb config --with=dbi,dbd_mysql
=>entering config phase…
=>config done.

ruby setup.rb config (with no options) works with
ruby setup.rb setup
ruby setup.rb install

but how do i test it now in Ruby? What test code?

With this test code:

#!/usr/bin/ruby -w

simple.rb - simple MySQL script using Ruby DBI module

require “dbi”

begin
# connect to the MySQL server
dbh = DBI.connect(“DBI:Mysql:test:localhost”, “testuser”,
“testpass”)
# get server version string and display it
row = dbh.select_one(“SELECT VERSION()”)
puts "Server version: " + row[0]
rescue DBI::DatabaseError => e
puts “An error occurred”
puts “Error code: #{e.err}”
puts “Error message: #{e.errstr}”
ensure
# disconnect from server
dbh.disconnect if dbh
end

I get this error

c:/ruby/lib/ruby/site_ruby/1.8/dbi.rb:329:in load_driver': Unable to load driver 'Mysql' (DBI::InterfaceError) from c:/ruby/lib/ruby/site_ruby/1.8/dbi.rb:227:in_get_full_driver’
from c:/ruby/lib/ruby/site_ruby/1.8/dbi.rb:213:in `connect’
from mysqltest.rb:8