suyesh suyesh - 1 year ago 84
Ruby Question

How to put a raw SQL query in Sequel

I am trying to convert SQL code to Seqel to run it from my script. How do I convert this:

select code, count(1) as total
from school_districts
group by code order by total desc;

into Sequel? Or, is there a way to pass raw SQL to Sequel? Also the
will be interpolated

Answer Source

You can do it a couple ways:

  1. Use []:

    DB["your sql string"]
  2. Use fetch:

    DB.fetch("your sql string")
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download