常常需要开发一些script,需要引用Rails的model
ENV['RAILS_ENV'] ||= 'production'
require File.dirname(__FILE__) + "/../config/environment"
还有一些需要直接查数据的操作
可以使用Mysql2
require 'mysql2'
client = Mysql2::Client.new(:host => "localhost", :username => "root")
client.query('use xxxxx')
fields = client.query("show fields from xxx_xxxx").each do |row|
row["Field"]
end