Topic: Access MySQL database


I need help accessing a MySQL database and reading in information from a table. I was able to do it by using the mysql2 gem directly, but the code is ugly. I wanted to be able to put this code into a model, in order to properly format the output.

I am unsure of how to do this or where to start. I don't want to write to the db, just read from it.

Re: Access MySQL database

You can use either DataMapper (, ActiveRecord ( or Sequel ( They operate slightly differently, but all of them will meet your needs.

Re: Access MySQL database

Yes, I went with activerecord. I just had to define which table I wanted to use and I was able to pull data from it. Thank you.