DBI connection problem

R

Reis

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 Reginato.
 
R

Reis

Daniel said:
<snip>

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 Reginato
 
D

Daniel Berger

Reis said:
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 Reginato

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
 
M

Monty Vanemmerik

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

Monty
 
S

Sonny Chee

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.
 

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

Similar Threads


Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top