Forum: Ruby DBI connection problem

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
4f4122bc3b9999d9050f0b1a10b63251?d=identicon&s=25 Reis (Guest)
on 2006-03-24 17:23
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.
F3b7b8756d0c7f71cc7460cc33aefaee?d=identicon&s=25 Daniel Berger (Guest)
on 2006-03-24 17:40
(Received via mailing list)
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
4f4122bc3b9999d9050f0b1a10b63251?d=identicon&s=25 Reis (Guest)
on 2006-03-24 17:48
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
F3b7b8756d0c7f71cc7460cc33aefaee?d=identicon&s=25 Daniel Berger (Guest)
on 2006-03-24 18:53
(Received via mailing list)
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
C7170effec81b3808125c63fdf4bff44?d=identicon&s=25 Monty Vanemmerik (mvanemmerik)
on 2006-12-10 22:39
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
9ea8229b9b6503cde77171ffcfe2eedc?d=identicon&s=25 Sonny Chee (soroe)
on 2007-04-18 02:18
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.
This topic is locked and can not be replied to.