On 29 Aug 2001 23:21:46 +0900, steved-clr / daviesfam.org wrote:
> Can anyone point me to example Ruby code that uses an SQL database.
> 
> My application stores TV schedules in a Postgres database etc.
> 
> I'd like to use a Ruby "style" to access the database - specific
> classes for rows from each table or view, etc.  But SQL relational
> style and Ruby object style don't really mesh very cleanly.
> 
> So basically I'm looking to see the approach that others have taken.
> 
> My apps will all be in Ruby so perhaps an SQL database is the wrong
> approach.  I'm also open to other suggestions!
> 


I've only used the ruby-dbi-layer as a test but I found it very nice and
pretty "rubyistic" as well.  You can do stuff like

foo.select_all("select a,b from table") { |a,b|
  do stuff with a and b
}

compare this to how you have to do under perl

my $sth = $foo.prepare("select a,b from table");
while(my $row = $sth->fetch()) {
   my ($a, $b) = @$row;
   do stuff with a and b
}

I think the ruby-way is alot nicer.. you can still do stuff the
"perl-way" in ruby.

It's is really really nice.  Check out the examples.  I don't think you
should be afraid of using ruby-dbi 

-- 
Erik B?gfors               | erik / bagfors.nu
Supporter of free software | GSM +46 733 279 273
fingerprint: 6666 A85B 95D3 D26B 296B 6C60 4F32 2C0B 693D 6E32
/Erik