Ruby and Databases

Is there a book or another collection of suggested readings for learning
how
to manipulate a database with ruby? I’ve gotten to the point where I can
take a CSV file, store it as an associative array, but now I’d like to
take
that and put it into a database (postgresql). Is there a sample of
commented
code to take a look at? Otherwise, I’m happy to read a few books or
articles
and piece what I need together.

Brian

On Sun, Aug 17, 2008 at 11:20 PM, Brian R. [email protected]
wrote:

Is there a book or another collection of suggested readings for learning how
to manipulate a database with ruby? I’ve gotten to the point where I can
take a CSV file, store it as an associative array, but now I’d like to take
that and put it into a database (postgresql). Is there a sample of commented
code to take a look at? Otherwise, I’m happy to read a few books or articles
and piece what I need together.

These days perhaps the most common way to deal with databases in Ruby
is using the ActiveRecord library (http://ar.rubyonrails.com/), which
originated as part of the Rails web framework. You will find loads of
ActiveRecord documention both on the web and in any book about Rails.

That’s not the only way, however. There are other Object-Relational
mapping layers (ORMs), such as DataMapper (http://datamapper.org/).
If you’re not necessarily looking for an ORM, you just want to
manipulate databases from Ruby, you might look into Sequel
(http://sequel.rubyforge.org/). Or, if you want to take a more
traditional approach, Ruby-DBI (http://ruby-dbi.rubyforge.org/) is one
of the most mature Ruby/database libraries.


Avdi

Home: http://avdi.org
Developer Blog: Avdi Grimm, Code Cleric
Twitter: http://twitter.com/avdi
Journal: http://avdi.livejournal.com