Help - MySql connect.

Discussion in 'Ruby' started by len, May 26, 2006.

  1. len

    len Guest


    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

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

    require "dbi"

    # connect to the MySQL server
    dbh = DBI.connect("dbi:Mysql:Northwind:localhost:3306", "root",
    # 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}"
    # disconnect from server
    dbh.disconnect if dbh

    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

    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
    len, May 26, 2006
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.

Share This Page