[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: Ruby DBI

Sharon Rosner

12/24/2007 9:19:00 PM

> What's the best way to do raw SQL in Ruby? Something like Perl's DBI. I see there is aRuby DBIbut it seems in beta. Can one

You can give Sequel a try. it provides a simple way to connect to
databases, and you can run raw SQL statements:

require 'sequel'
DB = Sequel('postgres://localhost/mydb')
DB['select * from my_table'].each do |row|
p row
end

You can also specify your queries in Ruby:

DB[:items].filter {:category == 'ruby' && :price <
100}.order(:name).each do |row|
p row
end

More info here:

http://code.google.com/p/r...
http://sequel.rub...
http://groups.google.com/group/s...