How to install Ruby DBI module?

J

Justin To

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!
 
J

Justin To

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. ...
 
S

Stefano Crocco

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
 
J

Justin To

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 */
 
J

Justin To

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
 
J

Justin To

Justin said:
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?
 
J

Justin To

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

DBI 2
Ruby DBI 3
How to install and use PhpSanitization 0
how to uninstall ruby-dbi-all 0
Ruby DBI Help Needed 0
Where to install ruby-dbi? 0
Translater + module + tkinter 1
[ANN] DBI 0.4.0 2

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top