0

I need to connect to a MySQL database. I've found a gem called "mysql" and one called "mysql2". I tried installing and using both gems and got a message like this:

cannot load such file -- mysql (LoadError)
C:/Automation/ta-rb5-portal-cuke/features/step_definitions/common_steps.rb:2:in
`require'
C:/Automation/ta-rb5-portal-cuke/features/step_definitions/common_steps.rb:2:in
`<top (required)>

Which gem should I use and what am I doing wrong?

I'm using Ruby 2.1.7.

the Tin Man
  • 158,662
  • 42
  • 215
  • 303
user3249517
  • 131
  • 1
  • 1
  • 6
  • 1
    You probably want to use [ActiveRecord](http://guides.rubyonrails.org/active_record_querying.html) or [Sequel](http://sequel.jeremyevans.net/) to connect to your database. Using the low-level driver is extremely messy. – tadman Sep 23 '15 at 21:14
  • also try loading these gems via [bundler](http://bundler.io/) and not relying on system installs (such as 'gem install mysql'). – hamitron Sep 23 '15 at 21:43
  • 1
    This seems awful close to a duplicate of http://stackoverflow.com/q/5411551/128421 – the Tin Man Sep 23 '15 at 21:53
  • The short answer to what you actually asked in the title is: you should use mysql2. But normally you'd use Sequel or ActiveRecord as higher level abstractions, with mysql2. And that doesn't answer your installation problems, which you might have with mysql2 as well. Ruby on Windows is painful. – jrochkind Sep 24 '15 at 02:15

0 Answers0