Help - MySql connect.

L

len

Hello

Trying to learn Ruby using MySql.

Ruby ver 1.8.2
MySQL ver 5.0
OS WinXP sp2

I have loaded the "Northwind" database into MySQL and have run a few
test queries which work fine. I copied the following code from
http://www.kitebird.com/articles:

# simple.rb - simple MySQL script using Ruby DBI module

require "dbi"

begin
# connect to the MySQL server
dbh = DBI.connect("dbi:Mysql:Northwind:localhost:3306", "root",
"cesare05")
# 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 the following error when I try and run:

C:\myruby>ruby testmysqlconnect.rb
c:/ruby/lib/ruby/site_ruby/1.8/dbi/dbi.rb:499:in `load_driver': is not
a class/
module (TypeError)
from c:/ruby/lib/ruby/site_ruby/1.8/dbi/dbi.rb:401:in
`_get_full_driver'

from c:/ruby/lib/ruby/site_ruby/1.8/dbi/dbi.rb:381:in `connect'
from testmysqlconnect.rb:7

I don't what the problem is -- can anyone help.

Len Sumnler
 

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
474,056
Messages
2,570,441
Members
47,101
Latest member
DoloresHol

Latest Threads

Top