Created
October 20, 2012 22:02
-
-
Save maxivak/3924988 to your computer and use it in GitHub Desktop.
Dynamic connection to MySQL database in Ruby on Rails (mysql2)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'mysql2' | |
db = Mysql2::Client.new(:host => 'localhost', :username => 'root', :password=> 'password', :database => 'db_name' ) | |
res = db.query("select * from users") | |
res.each do |row| | |
col1 = row['id'] | |
col2 = row['email'] | |
.. | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment