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:atabaseError => 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
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:atabaseError => 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