[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

DBI connection problem

Andrea Reginato

3/24/2006 4:24:00 PM

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.

--
Posted via http://www.ruby-....


4 Answers

Andrea Reginato

3/24/2006 4:49:00 PM

0

Daniel Berger wrote:
> Reis wrote:
>> # connect to the MySQL server
>> dbh.disconnect if dbh
>> end
>> ------------------------------------------------
>>
>> But i have this error.
>
> <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

--
Posted via http://www.ruby-....


Berger, Daniel

3/24/2006 5:53:00 PM

0

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


Monty Vanemmerik

12/10/2006 9:40:00 PM

0

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 Reginato


--
Posted via http://www.ruby-....

Sonny Chee

4/18/2007 12:18:00 AM

0

Hey Guys,

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

http://www.vandomburg.net/pages/mysql-ru...

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.

--
Posted via http://www.ruby-....