« Return to Thread: Using DBI and MySQL gems

Re: Using DBI and MySQL gems

by Owein Herrmann :: Rate this Message:

Reply to Author | View in Thread

Erik Hollensbe wrote:

> require "rubygems"
> require "dbi"
What about the mysql package? Don't you have to do something to load
that?

>     dbh = DBI.connect("DBI:Mysql:rubytest:localhost", "root")
Using the lines above, this is where is breaks. It cannot locate the
mysql driver. If I add "require 'mysql'", then I get:
DBI::InterfaceError: Could not load driver (uninitialized constant
Mysql::Driver)
        from c:/ruby/lib/ruby/site_ruby/1.8/dbi.rb:344:in `load_driver'
        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'

The only correct way I have to initialize these packages for use seems
to be using the "gem" command, and then I have to require "dbi". Oh
well. At least it works.

> If this breaks on your system, I'd be looking elsewhere (of ruby,
> rubygems, and dbi... likely in the direction of your package
> maintainers) to solve your problem.

I'm not sure what you mean by package maintainers...
--
Posted via http://www.ruby-forum.com/.

 « Return to Thread: Using DBI and MySQL gems