Forums | Admin

Discussion Forums: open-discussion

Start New Thread Start New Thread

 

By: Saad Mahamood
RE: Using DBI on Mac OS X and MySQL [ reply ]  
2007-08-18 23:05
Ah! I haven't installed the MySQL/Ruby driver. I'll have to do that!

Thanks!

By: Francis Hwang
RE: Using DBI on Mac OS X and MySQL [ reply ]  
2007-08-18 14:20
The install isn't as easy as it could be. I think what you need to do now is install the underlying MySQL/Ruby driver. Try the instructions on this page:

http://lafcadio.rubyforge.org/manual/ch02s02.html


By: Saad Mahamood
Using DBI on Mac OS X and MySQL [ reply ]  
2007-08-18 13:35
Hello,

I've installed successfully DBI using Ruby 1.8.6 on Mac OS X 10.4.10. The problem I'm having is that I can't connect to a MySQL database since the error I get is the following:

$ty5:~/Desktop ty5$ ruby dbconnect.rb
/usr/local/lib/ruby/site_ruby/1.8/dbi.rb:344:in `load_driver': Could not load driver (no such file to load -- mysql) (DBI::InterfaceError)
from /usr/local/lib/ruby/site_ruby/1.8/dbi.rb:227:in `_get_full_driver'
from /usr/local/lib/ruby/site_ruby/1.8/dbi.rb:213:in `connect'
from dbconnect.rb:9

I've checked that the MySQL driver for DBI is installed and it is:

ty5:/usr/local/lib/ruby/site_ruby/1.8/DBD/Mysql ty5$ ls -l
total 40
-rw-r--r-- 1 root wheel 19857 Aug 18 13:50 Mysql.rb

And so is the Postgres driver:

ty5:/usr/local/lib/ruby/site_ruby/1.8/DBD/Pg ty5$ ls -l
total 56
-rw-r--r-- 1 root wheel 24630 Aug 18 14:18 Pg.rb

The connect code I'm using is:

dbh = DBI.connect('DBI:Mysql:test', 'username', 'password')

So I'm kind of stuck at this point since everything seems correct to me! Any help would be most welcomed!

Thanks!