Wednesday, April 14, 2010

Executing sql from rails console

All ways useful...

ActiveRecord::Base.connection.execute("SELECT * FROM users")
ActiveRecord::Base.connection.execute("select * from customers").fetch_row
results = ActiveRecord::Base.connection.execute("select * from customers")

while row = results.fetch_row do
# process row here
end

No comments:

Post a Comment