# Get attributes from database

**URL:** <https://www.ruby-forum.com/t/get-attributes-from-database/161100>\
**Category:** Ruby\
**Created:** [February 23, 2009, 12:26pm UTC](https://www.ruby-forum.com/t/get-attributes-from-database/161100 "2009-02-23T12:26:41Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jobber](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/848f3c/32.png) [@jobber](https://www.ruby-forum.com/u/jobber)\
**Post date:** [February 23, 2009, 12:26pm UTC](https://www.ruby-forum.com/t/get-attributes-from-database/161100/1 "2009-02-23T12:26:41Z")

</div>

Hello all,

i have a class Inpatient with his attributes like name, address, etc.

i want to catch the inpatient data from database, how i can do this?

i want add inpatients when i give the name, and so all attributes of  
this  
inpatient should come from database.

i hope i could define my prolem.

how can i implement this with ruby?

greet

---

<div class="post-metadata">

**Author:** ![jobber](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/848f3c/32.png) [@jobber](https://www.ruby-forum.com/u/jobber)\
**Post date:** [February 23, 2009, 12:59pm UTC](https://www.ruby-forum.com/t/get-attributes-from-database/161100/2 "2009-02-23T12:59:28Z")

</div>

On Mon, Feb 23, 2009 at 12:26 PM, Hello G. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> i hope i could define my prolem.
> 
> how can i implement this with ruby?

What you want is usually called ORM: Object-Relational Mapping, which  
is a way to map data from a database into objects in a programming  
language. In Ruby there are several implementations, you should check  
some of them and choose one that suits your project. The most popular  
ones (as perceived by me 🙂 are ActiveRecord, Sequel and DataMapper.  
You can use google to find documentation about those.

Hope this helps,

Jesus.

---

<div class="post-metadata">

**Author:** ![jobber](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/848f3c/32.png) [@jobber](https://www.ruby-forum.com/u/jobber)\
**Post date:** [February 23, 2009, 8:04pm UTC](https://www.ruby-forum.com/t/get-attributes-from-database/161100/3 "2009-02-23T20:04:24Z")

</div>

JesÃºs Gabriel y GalÃ¡n wrote:

> On Mon, Feb 23, 2009 at 12:26 PM, Hello G. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> wrote:
> 
> > i hope i could define my prolem.
> > 
> > how can i implement this with ruby?
> 
> What you want is usually called ORM: Object-Relational Mapping, which  
> is a way to map data from a database into objects in a programming  
> language. In Ruby there are several implementations, you should check  
> some of them and choose one that suits your project. The most popular  
> ones (as perceived by me 🙂 are ActiveRecord, Sequel and DataMapper.  
> You can use google to find documentation about those.
> 
> Hope this helps,
> 
> Jesus.

thanks for your answer. i dont know if i have good defined my problem:  
i have a separat program which calls inpatient.rb. and here is my class  
inpatient, that should take data from database. is the mapping with orm  
here right?
