MySQL, Ruby, DBI connetc problem...help please

I currently have the MySQL binary for Windows installed. I have ruby under
both cygwin and windows installed. I can not get the DBI module for either
ruby version to connect to my mysql database. Here is the code:

require 'dbi' # so far so good

dbh = DBI.connect('DBI:Mysql:test', 'testuser', 'testpwd') # here's
where it crashes
from /usr/lib/ruby/site_ruby/1.8/dbi/dbi.rb:499:in `load_driver'
from /usr/lib/ruby/site_ruby/1.8/dbi/dbi.rb:401:in `_get_full_driver'
from /usr/lib/ruby/site_ruby/1.8/dbi/dbi.rb:381:in `connect'
from (irb):5

I thought that maybe I had to declare the host so:

dbh = DBI.connect('DBI:Mysql:test:.', 'testuser', 'testpwd') # here's
where it crashes
from /usr/lib/ruby/site_ruby/1.8/dbi/dbi.rb:499:in `load_driver'
from /usr/lib/ruby/site_ruby/1.8/dbi/dbi.rb:401:in `_get_full_driver'
from /usr/lib/ruby/site_ruby/1.8/dbi/dbi.rb:381:in `connect'
from (irb):5

I thought maybe there was something wrong with the database but the
following connects just fine in the terminal:

mysql -u testuser -p -h . test

I can not seem to get the DBI to work with Windows, apparently the ruby
modules are only good with Unix and not Windows. Please do not say try
mysql-ruby. I can not even get that to compile. I've tried compiling Mysql
source for the libs but it still refuses to find the mysql libs no matter
wher I point extcong.rb. So I tried going back to DBI. That is where I stand
now. Certainly someone out there has been able to get this module to work
properly with the MySQL binary install and WinXP?

Thanks:)

SA

···

--
"I can do everything on my Mac that I could do on a PC."
-- Me

use mysql-administrator & check the
Startup Parameters->Security->Use Old Passwords checkbox
restart mysql server
try again.

I'm assuming you've got this installed:
http://ruby-dbi.sourceforge.net/

What did I do to get this to work?

> odbcad32

click system dsn, choose add.

Look for MySQL at the bottom.. if it's not there, download and install it:
http://dev.mysql.com/get/Downloads/MyODBC3/MyODBC-3.51.11-2-win.msi/from/pick

Afer installing it, click add again within the odbcad32 window, and
select the mysql driver..

put in the hostname and db details.. give the connector a name which
you will use with the connection shizza... test the connection then
close..

Create the ruby script to test it..
This example pretty much worked for me:

require 'dbi'

# connect to a datbase
dbh = DBI.connect('DBI:Mysql:test', 'testuser', 'testpwd')

puts "selecting..."
sth=dbh.prepare('select * from simple01')
sth.execute

while row=sth.fetch do
p row
end

···

On 9/16/05, Sean Armstrong <phinsxiii@gmail.com> wrote:

I currently have the MySQL binary for Windows installed. I have ruby under
both cygwin and windows installed. I can not get the DBI module for either
ruby version to connect to my mysql database. Here is the code:

require 'dbi' # so far so good

dbh = DBI.connect('DBI:Mysql:test', 'testuser', 'testpwd') # here's
where it crashes
from /usr/lib/ruby/site_ruby/1.8/dbi/dbi.rb:499:in `load_driver'
from /usr/lib/ruby/site_ruby/1.8/dbi/dbi.rb:401:in `_get_full_driver'
from /usr/lib/ruby/site_ruby/1.8/dbi/dbi.rb:381:in `connect'
from (irb):5

I thought that maybe I had to declare the host so:

dbh = DBI.connect('DBI:Mysql:test:.', 'testuser', 'testpwd') # here's
where it crashes
from /usr/lib/ruby/site_ruby/1.8/dbi/dbi.rb:499:in `load_driver'
from /usr/lib/ruby/site_ruby/1.8/dbi/dbi.rb:401:in `_get_full_driver'
from /usr/lib/ruby/site_ruby/1.8/dbi/dbi.rb:381:in `connect'
from (irb):5

I thought maybe there was something wrong with the database but the
following connects just fine in the terminal:

mysql -u testuser -p -h . test

I can not seem to get the DBI to work with Windows, apparently the ruby
modules are only good with Unix and not Windows. Please do not say try
mysql-ruby. I can not even get that to compile. I've tried compiling Mysql
source for the libs but it still refuses to find the mysql libs no matter
wher I point extcong.rb. So I tried going back to DBI. That is where I stand
now. Certainly someone out there has been able to get this module to work
properly with the MySQL binary install and WinXP?

Thanks:)

SA

--
"I can do everything on my Mac that I could do on a PC."
-- Me

Hello,

I'm new to Ruby (quite new to programming in general) and I've very
much been enjoying reading the posts here, although a lot of it goes
way over my head. Anyway, I was looking for some help connecting to
MySQL on Windows, came across this thread and managed to get a
connection using the MyODBC method. Only thing is, the connection
arguments needs to read thus for ODBC:

dbh = DBI.connect("DBI:ODBC:MyODBCdatasourcename, "user", "pass")

Probably obvious to most folks, but I thought I'd pass it on in the
spirit of sharing :slight_smile:

One question: what are the disadvantages of using ODBC over a native
driver? Is it just a performance issue?

Cheers,

Charles

You might also encounter some limitations of the ODBC driver in use.
There can be features available in the DB server SQL implementation,
which the "generic" ODBC driver simply does/will/can not offer.

s.

···

On 21 Sep 2005 11:49:50 -0700, Charles Roper <charles.roper@gmail.com> wrote:

One question: what are the disadvantages of using ODBC over a native
driver? Is it just a performance issue?

Many thanks for the reply. Can you offer any examples of what might not
work?

Charles

Not off the top of my head, sorry.

What I do remember is that I ran into problems with some
faulty ODBC drivers for Paradox, silently messing up simple joins.
Accessing the same tables via BDE from Delphi (i.e. "natively" worked,
but reading the data failed miserably from each of Ruby, Dolphin Smalltalk
and VB6, too.

On a side note, I've implemented a small access layer to MySQL for
a windows-based Forth environment. Since the C-level API is based on
strings, this was very easy for me as interface implementor.
ODBC offers a much richer set of datatypes, which makes life for the
end user more convenient (you get numbers from number columns).

s.

···

On 21 Sep 2005 14:19:37 -0700, Charles Roper <charles.roper@gmail.com> wrote:

Many thanks for the reply. Can you offer any examples of what might not
work?