Rails Query Database Without ActiveRecord

The official logo of the database query MySQL ...
The official logo of the database query MySQL Slovenčina: Oficiálne logo dotazovací databázy MySQL (Photo credit: Wikipedia)
Hi all,

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
SQL Humor (Photo credit: travis_warren123)

I hope this article can help you.
Enhanced by Zemanta

Komentar

Postingan populer dari blog ini

EPrT English Proficiency Test Soal - soal

cara memunculkan dan menyembunyikan icon date, time, clock, volume, network, power battery, action center pada taskbar pada Windows 7

Cara Mengurus Perpanjang SIM dan Rincian Biaya di Lumajang.