# Ruby and Databases

**URL:** <https://www.ruby-forum.com/t/ruby-and-databases/146111>\
**Category:** Ruby\
**Created:** [August 18, 2008, 5:24am UTC](https://www.ruby-forum.com/t/ruby-and-databases/146111 "2008-08-18T05:24:54Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![circlefusion](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/ea666f/32.png) [@circlefusion](https://www.ruby-forum.com/u/circlefusion)\
**Post date:** [August 18, 2008, 5:24am UTC](https://www.ruby-forum.com/t/ruby-and-databases/146111/1 "2008-08-18T05:24:54Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![circlefusion](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/ea666f/32.png) [@circlefusion](https://www.ruby-forum.com/u/circlefusion)\
**Post date:** [August 18, 2008, 5:41am UTC](https://www.ruby-forum.com/t/ruby-and-databases/146111/2 "2008-08-18T05:41:51Z")

</div>

On Sun, Aug 17, 2008 at 11:20 PM, Brian R. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
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/](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/](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/](http://sequel.rubyforge.org/)). Or, if you want to take a more  
traditional approach, Ruby-DBI ([http://ruby-dbi.rubyforge.org/](http://ruby-dbi.rubyforge.org/)) is one  
of the most mature Ruby/database libraries.

–  
Avdi

Home: [http://avdi.org](http://avdi.org)  
Developer Blog: [Avdi Grimm, Code Cleric](http://avdi.org/devblog/)  
Twitter: [http://twitter.com/avdi](http://twitter.com/avdi)  
Journal: [http://avdi.livejournal.com](http://avdi.livejournal.com)
