DBI connection problem


#1

I’m trying to use dbi to connect to MySQL 4.0.18 on windows XP
professional.

I have used a test with this code


simple.rb - simple MySQL script using Ruby DBI module

require “dbi”

begin

connect to the MySQL server

dbh = DBI.connect(“dbi:Mysql:test:localhost”, “testuser”, “testpass”)

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

But i have this error.


load_driver': Unable to load driver 'Mysql' (DBI::InterfaceError) from c:/ruby/lib/ruby/site_ruby/1.8/dbi.rb:227:in_get_full_driver’
from c:/ruby/lib/ruby/site_ruby/1.8/dbi.rb:213:in `connect’
from test_dbi.rb:6

When i have installed ruby-dbi i have run this command


% ruby setup.rb config --with=dbi,dbd_mysql
% ruby setup.rb setup
% ruby setup.rb install

Could be the problem the version of MySQL?

Thanks so much
–Andrea R…


#2

Reis wrote:

connect to the MySQL server

dbh.disconnect if dbh

end

But i have this error.

It looks like you have the DBD but don’t have the underlying MySQL
driver.
Remember, the DBD is just the frontend to the driver, not the driver
itself.

Regards,

Dan


#3

Reis wrote:

Thanks Dan.
But now where can i fount the driver for the access.
I have tried to install mysql-ruby-2.7.tar.gz but gives me errors during
the installation.
I’m new and i found some problem to understand what you intend for
‘driver’

Thanks so much
–Andrea R.

When I say ‘driver’, I mean the actual interface to the database,
probably a C
extension. The DBD is just a common interface wrapper over the top of
that.

I’m not familiar with how to install MySQL on Windows but I know others
have
gone through the process. If you search comp.lang.ruby (or google) for
“ruby”

  • “mysql” + “windows” I suspect you’ll find the answer you’re looking
    for.

Regards,

Dan


#4

Andrea,
Did you ever figure this out? I’m having the exact same problem.

Monty

Thanks Dan.
But now where can i fount the driver for the access.
I have tried to install mysql-ruby-2.7.tar.gz but gives me errors during
the installation.
I’m new and i found some problem to understand what you intend for
‘driver’

Thanks so much
–Andrea R.


#5

Daniel B. wrote:

Reis wrote:

connect to the MySQL server

dbh.disconnect if dbh

end

But i have this error.

It looks like you have the DBD but don’t have the underlying MySQL
driver.
Remember, the DBD is just the frontend to the driver, not the driver
itself.

Regards,

Dan

Thanks Dan.
But now where can i fount the driver for the access.
I have tried to install mysql-ruby-2.7.tar.gz but gives me errors during
the installation.
I’m new and i found some problem to understand what you intend for
‘driver’

Thanks so much
–Andrea R.


#6

Hey Guys,

I’m having the same problem. I found the following link and followed
the install directions.

http://www.vandomburg.net/pages/mysql-ruby-windows

I even confirmed that the mysql driver was installed by running the
suggested code snippet:

require 'mysql'
puts Mysql::VERSION

which echoed to stdout 20703 as expected. However, when I attempt the
following, I get the "InterfaceError: could not load driver
(uninitialized constant Mysql::Driver).

Any help from a DBI guru would be appreciated.

Sonny.