Gems for DBI and MySQL?

You can go to http://ruby-dbi.sourceforge.net/ to download the package, as
it doesn't come bundled with the Ruby One-Click Installer for Windows.
Installation isn't too bad. Just follow the documentation that comes with
the package...

···

-----Original Message-----
From: R. Mark Volkmann [mailto:mark@ociweb.com]
Sent: Wednesday, March 30, 2005 10:39 AM
To: ruby-talk@ruby-lang.org
Subject: gems for DBI and MySQL?

My apologies for incorrectly posting this on my first try.
I'm reposting it to it's own thread.

I need to access a MySQL database from Ruby.
I'm running under Windows using the one-click installer.
Is DBI the preferred way to do that?

If so, what do I need to install that doesn't come bundled in the one-click
installer? DBI? Ruby MySQL driver?

Are there gems for those or do I need to install them the old fashioned way?

--
R. Mark Volkmann
Partner, Object Computing, Inc.

Quoting "Kujawa, Greg" <Greg.Kujawa@DiamondCellar.com>:

You can go to http://ruby-dbi.sourceforge.net/ to download the package, as
it doesn't come bundled with the Ruby One-Click Installer for Windows.
Installation isn't too bad. Just follow the documentation that comes with
the package...

Downloading DBI is easy enough. However, I think I also need a database driver
(DBD) for MySQL. The page you referenced above says

"MySQL (dbd_mysql)

depend on the "MySQL Ruby Module" by TOMITA Masahiro <tommy@tmtm.org>
<URL:http://www.tmtm.org/mysql/&gt; or available from the RAA."

I doesn't appear that it can be downloaded from that URL and I can't find
anything in the RAA that claims to be a DBD from MySQL. Can someone tell me
the name of the thing I should looking for?

Maybe it's just me, but it doesn't seem like setting up Ruby to work with MySQL
is very well documented.

···

-----Original Message-----
From: R. Mark Volkmann [mailto:mark@ociweb.com]
Sent: Wednesday, March 30, 2005 10:39 AM
To: ruby-talk@ruby-lang.org
Subject: gems for DBI and MySQL?

My apologies for incorrectly posting this on my first try.
I'm reposting it to it's own thread.

I need to access a MySQL database from Ruby.
I'm running under Windows using the one-click installer.
Is DBI the preferred way to do that?

If so, what do I need to install that doesn't come bundled in the one-click
installer? DBI? Ruby MySQL driver?

Are there gems for those or do I need to install them the old fashioned way?

--
R. Mark Volkmann
Partner, Object Computing, Inc.

--
R. Mark Volkmann
Partner, Object Computing, Inc.

The DBD for Mysql is included in the DBI package. But each DBD depends on some
external modules, in case of DBD::Mysql, this is the above mentioned MySQL
Ruby Module by TOMITA Masashiro.

Regards,

  Michael

···

Am Mittwoch 30 März 2005 21:39 schrieb R. Mark Volkmann:

Quoting "Kujawa, Greg" <Greg.Kujawa@DiamondCellar.com>:
> You can go to http://ruby-dbi.sourceforge.net/ to download the package,
> as it doesn't come bundled with the Ruby One-Click Installer for Windows.
> Installation isn't too bad. Just follow the documentation that comes with
> the package...

Downloading DBI is easy enough. However, I think I also need a database
driver (DBD) for MySQL. The page you referenced above says

"MySQL (dbd_mysql)

depend on the "MySQL Ruby Module" by TOMITA Masahiro <tommy@tmtm.org>
<URL:http://www.tmtm.org/mysql/&gt; or available from the RAA."

I doesn't appear that it can be downloaded from that URL and I can't find
anything in the RAA that claims to be a DBD from MySQL. Can someone tell
me the name of the thing I should looking for?

As posted by Vraj Mohan, the procedure for setting up Ruby access to MySQL under
Windows is quite involved. See http://seagecko.org/thoughts/index.php?p=28\.

Does Rails use DBI to access databases?
Does Rails support MySQL out of the box?
I'm not writing a web app. However, if the answer to both questions above is
"yes" then it would seem that the easiest way to get myself setup to use MySQL
would be to install Rails. True?

Quoting Michael Neumann <mneumann@ntecs.de>:

···

Am Mittwoch 30 März 2005 21:39 schrieb R. Mark Volkmann:
> Quoting "Kujawa, Greg" <Greg.Kujawa@DiamondCellar.com>:
> > You can go to http://ruby-dbi.sourceforge.net/ to download the package,
> > as it doesn't come bundled with the Ruby One-Click Installer for Windows.
> > Installation isn't too bad. Just follow the documentation that comes with
> > the package...
>
> Downloading DBI is easy enough. However, I think I also need a database
> driver (DBD) for MySQL. The page you referenced above says
>
> "MySQL (dbd_mysql)
>
> depend on the "MySQL Ruby Module" by TOMITA Masahiro <tommy@tmtm.org>
> <URL:http://www.tmtm.org/mysql/&gt; or available from the RAA."
>
> I doesn't appear that it can be downloaded from that URL and I can't find
> anything in the RAA that claims to be a DBD from MySQL. Can someone tell
> me the name of the thing I should looking for?

The DBD for Mysql is included in the DBI package. But each DBD depends on
some
external modules, in case of DBD::Mysql, this is the above mentioned MySQL
Ruby Module by TOMITA Masashiro.

Regards,

  Michael

--
R. Mark Volkmann
Partner, Object Computing, Inc.

R. Mark Volkmann wrote:

Does Rails use DBI to access databases?

No.

Does Rails support MySQL out of the box?
I'm not writing a web app. However, if the answer to both questions above
is "yes" then it would seem that the easiest way to get myself setup to
use MySQL
would be to install Rails. True?

No.

It's easy to just do it by hand.

Get mysql-ruby (http://tmtm.org/en/mysql/ruby/README.html\), which is the C
interface, or ruby-mysql (http://tmtm.org/en/ruby/mysql/README_en.html\),
which is the pure Ruby interface. Follow the easy instructions to build
this.

Download DBI (http://rubyforge.org/projects/ruby-dbi\).

After unpacking ruby-dbi:

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

You'll be good to go.

Kirk Haines

As posted by Vraj Mohan, the procedure for setting up Ruby access to MySQL
under Windows is quite involved. See
http://seagecko.org/thoughts/index.php?p=28\.

Does Rails use DBI to access databases?

No.

Does Rails support MySQL out of the box?

No.

I'm not writing a web app. However, if the answer to both questions above
is "yes" then it would seem that the easiest way to get myself setup to use
MySQL would be to install Rails. True?

You still need the MySQL module and this is what might be troublesome (because
you have to compile it).

Regards,

  Michael

···

Am Donnerstag 31 März 2005 17:19 schrieb R. Mark Volkmann:

Michael Neumann wrote:

···

Am Donnerstag 31 März 2005 17:19 schrieb R. Mark Volkmann:

Does Rails support MySQL out of the box?

No.

Yes, it includes ruby-mysql.

Quoting Kirk Haines <khaines@enigo.com>:

R. Mark Volkmann wrote:

> Does Rails use DBI to access databases?

No.

> Does Rails support MySQL out of the box?
> I'm not writing a web app. However, if the answer to both questions above
> is "yes" then it would seem that the easiest way to get myself setup to
> use MySQL
> would be to install Rails. True?

No.

It's easy to just do it by hand.

Get mysql-ruby (http://tmtm.org/en/mysql/ruby/README.html\), which is the C
interface, or ruby-mysql (http://tmtm.org/en/ruby/mysql/README_en.html\),
which is the pure Ruby interface. Follow the easy instructions to build
this.

Download DBI (http://rubyforge.org/projects/ruby-dbi\).

After unpacking ruby-dbi:

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

This last step is a problem when you've installed Ruby using the one-click
installer because it tries to overwrite existing .rb files. I had to delete
the existing ones to get this to work.

You'll be good to go.

When I run my code that contains

  dbh = DBI.connect('dbi:Mysql:music:localhost', 'root', '')

I get

c:/Ruby/Ruby1.8.2-14/lib/ruby/site_ruby/1.8/dbi/dbi.rb:490:in `load_driver': is
not a class/module (TypeError)
        from c:/Ruby/Ruby1.8.2-14/lib/ruby/site_ruby/1.8/dbi/dbi.rb:392:in `_get
_full_driver'
        from c:/Ruby/Ruby1.8.2-14/lib/ruby/site_ruby/1.8/dbi/dbi.rb:372:in
`connect'

I looked at the code. I think it's complaining about not being able to find a
class called DBI::DriverHandle. That class is defined in dbi.rb.

Any idea what's going on here?

···

--
R. Mark Volkmann
Partner, Object Computing, Inc.

Oh great! Sorry for the confusion.

Regards,

  Michael

···

Am Freitag 01 April 2005 00:19 schrieb Andreas Schwarz:

Michael Neumann wrote:
> Am Donnerstag 31 März 2005 17:19 schrieb R. Mark Volkmann:
>>Does Rails support MySQL out of the box?
>
> No.

Yes, it includes ruby-mysql.

Quoting Kirk Haines <khaines@enigo.com>:
> R. Mark Volkmann wrote:
> > Does Rails use DBI to access databases?
>
> No.
>
> > Does Rails support MySQL out of the box?
> > I'm not writing a web app. However, if the answer to both questions
> > above is "yes" then it would seem that the easiest way to get myself
> > setup to use MySQL
> > would be to install Rails. True?
>
> No.
>
> It's easy to just do it by hand.
>
> Get mysql-ruby (http://tmtm.org/en/mysql/ruby/README.html\), which is the
> C interface, or ruby-mysql
> (http://tmtm.org/en/ruby/mysql/README_en.html\), which is the pure Ruby
> interface. Follow the easy instructions to build this.
>
> Download DBI (http://rubyforge.org/projects/ruby-dbi\).
>
> After unpacking ruby-dbi:
>
> ruby setup.rb config --with=dbi,dbd_mysql
> ruby setup.rb setup
> ruby setup.rb install

This last step is a problem when you've installed Ruby using the one-click
installer because it tries to overwrite existing .rb files. I had to
delete the existing ones to get this to work.

Or you simply remove the "dbi" from the --with option:

  ruby setup.rb config --with=dbd_mysql

> You'll be good to go.

When I run my code that contains

  dbh = DBI.connect('dbi:Mysql:music:localhost', 'root', '')

I get

c:/Ruby/Ruby1.8.2-14/lib/ruby/site_ruby/1.8/dbi/dbi.rb:490:in
`load_driver': is not a class/module (TypeError)
        from c:/Ruby/Ruby1.8.2-14/lib/ruby/site_ruby/1.8/dbi/dbi.rb:392:in
`_get _full_driver'
        from c:/Ruby/Ruby1.8.2-14/lib/ruby/site_ruby/1.8/dbi/dbi.rb:372:in
`connect'

You don't have the ruby-mysql or mysql-ruby library installed, do you?

I looked at the code. I think it's complaining about not being able to
find a class called DBI::DriverHandle. That class is defined in dbi.rb.

Any idea what's going on here?

I think, it loads the DBD, but the first (or one of the first) lines of the
DBD/Mysql/Mysql.rb file fails, as this loads the "mysql" library, which is
probably not installed.

Regards,

  Michael

···

Am Samstag 02 April 2005 05:21 schrieb R. Mark Volkmann: