suyesh suyesh - 1 year ago 90
Ruby Question

Putting raw 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 school_districts will be interpolated #{table_name}

Answer Source

you can do it using few 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