From: Michael Neumann Date: 2005-04-02T21:49:59+09:00 Subject: Re: gems for DBI and MySQL? Am Samstag 02 April 2005 05:21 schrieb R. Mark Volkmann: > Quoting Kirk Haines : > > 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