TypeError in using MySQL driver

E

Ed Bayudan

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?
 
E

Ed Bayudan

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.
 

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

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,526
Members
44,997
Latest member
mileyka

Latest Threads

Top