Rails Query Database Without ActiveRecord
| The official logo of the database query MySQL Slovenčina: Oficiálne logo dotazovací databázy MySQL (Photo credit: Wikipedia) |
I want to share to query Mysql without ActiveRecord (find_by_sql, or where, or connection).
Please follow me to query
1. Please go to rails console
2. And and the this line.
config = ActiveRecord::Base.configurations[Rails.env]
connect = Mysql2::Client.new(config)
data = connect.query("SELECT * FROM users")
data.map {|user| user["email"]}| SQL Humor (Photo credit: travis_warren123) |
I hope this article can help you.
Comments
Post a Comment