Getting SQL results in Ruby

So you want run some generic SQL in Ruby an a result – like the number of users

sql = "select count(*) as amount from users"
result = connection.execute(sql).fetch_row
amount = result[0].to_f

Leave a Reply

Your email address will not be published. Required fields are marked *