TypeError in using MySQL driver


#1

I get a ‘TypeError’ when I run the following script:

require ‘dbi’
dbi = DBI.connect(‘DBI:Mysql:wrdb_development’, ‘root’, ‘’) do |dbh|
end

C:/Rails/InstantRails/ruby/lib/ruby/site_ruby/1.8/dbi/dbi.rb:501:in
`load_driver’: is not a class/module (TypeError)

This after installing the following gems:
mysql-2.7.3-mswin32
dbd-mysql-0.4.2
dbi-0.4.1
deprecated-2.0.1

I am running InstantRails in WinXP

I’ve searched all over and the solutions I’ve found have not fixed this
problem.
I did notice that installing the above gems did not create MySQL driver
directories in
C:/Rails/InstantRails/ruby/lib/ruby/site_ruby/1.8/DBD/

I only see ‘ODBC’ and ‘Proxy’ directories.

Are there additional setup scripts I need to run?


#2

This did the trick for me:

  1. Downloaded dbi-04.1.zip then expanded it in a temp directory

  2. Ran the following scripts in the temp directory:
    2.a ruby setup.rb config
    2.b ruby setup.rb setup
    2.c ruby setup.rb install

These steps created additional files in the
\ruby\lib\ruby\site_ruby\1.8\dbi directory which were not generated when
I first installed the dbi-0.4.1 gem

These commands now work:

require ‘dbi’
dbi = DBI.connect(‘DBI:Mysql:wrdb_development’, ‘root’, ‘’) do |dbh|
sth = dbh.prepare(‘select * from testtable’)
sth.execute

Print out each row

while row=sth.fetch do
p row
end
end

Hopefully with this out of the way, I’d be able to run stored procedures
as well.

Ed Bayudan wrote:

I get a ‘TypeError’ when I run the following script:

require ‘dbi’
dbi = DBI.connect(‘DBI:Mysql:wrdb_development’, ‘root’, ‘’) do |dbh|
end

C:/Rails/InstantRails/ruby/lib/ruby/site_ruby/1.8/dbi/dbi.rb:501:in
`load_driver’: is not a class/module (TypeError)

This after installing the following gems:
mysql-2.7.3-mswin32
dbd-mysql-0.4.2
dbi-0.4.1
deprecated-2.0.1

I am running InstantRails in WinXP

I’ve searched all over and the solutions I’ve found have not fixed this
problem.
I did notice that installing the above gems did not create MySQL driver
directories in
C:/Rails/InstantRails/ruby/lib/ruby/site_ruby/1.8/DBD/

I only see ‘ODBC’ and ‘Proxy’ directories.

Are there additional setup scripts I need to run?