# Dtabase access with Ruby

**URL:** <https://www.ruby-forum.com/t/dtabase-access-with-ruby/147584>\
**Category:** Ruby\
**Created:** [September 3, 2008, 1:03pm UTC](https://www.ruby-forum.com/t/dtabase-access-with-ruby/147584 "2008-09-03T13:03:33Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![sijo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/da6949/32.png) [@sijo](https://www.ruby-forum.com/u/sijo)\
**Post date:** [September 3, 2008, 1:03pm UTC](https://www.ruby-forum.com/t/dtabase-access-with-ruby/147584/1 "2008-09-03T13:03:33Z")

</div>

Hi  
If myb doubt is a stupidity please forgive…I was reading a ruby  
book as part of learning Ruby and I reached heading accessing database  
with Ruby I have installed and running rails project…In the book it  
says two methoda to connect a ruby program to database .  
Ruby/DBI and  
Ruby/odbc  
And for the sample program one require “dbi” and other require “odbc”  
I tried both these but getting no file to load? So my doubt is if these  
are the two methods for accessing database from Ruby how could I access  
database without anyof these two in Rails ?Is rails strategy differnet?  
I did not understand That is why asking Could you please explain with a  
simple code fragment to how a simple ruby program can be connected to  
the database I am using postgres And another doubt is if I install dbi  
will there any conflict with existing rails functionality?

Thanks in advance  
Sijo

---

<div class="post-metadata">

**Author:** ![sijo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/da6949/32.png) [@sijo](https://www.ruby-forum.com/u/sijo)\
**Post date:** [September 3, 2008, 2:20pm UTC](https://www.ruby-forum.com/t/dtabase-access-with-ruby/147584/2 "2008-09-03T14:20:10Z")

</div>

> And for the sample program one require “dbi” and other require “odbc”  
> I tried both these but getting no file to load? So my doubt is if these  
> are the two methods for accessing database from Ruby how could I access  
> database without anyof these two in Rails ?Is rails strategy differnet?  
> I did not understand That is why asking Could you please explain with a  
> simple code fragment to how a simple ruby program can be connected to  
> the database I am using postgres And another doubt is if I install dbi  
> will there any conflict with existing rails functionality?
> 
> Thanks in advance  
> Sijo

shouldn’t be a conflict  
I know you can find some postgres rails examples [google “postgres  
rails”] however I did’t see any easy links out there to how to just use  
the postgres gem by itself [no rails].  
Cheers.  
-=R

---

<div class="post-metadata">

**Author:** ![sijo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/da6949/32.png) [@sijo](https://www.ruby-forum.com/u/sijo)\
**Post date:** [September 3, 2008, 4:16pm UTC](https://www.ruby-forum.com/t/dtabase-access-with-ruby/147584/3 "2008-09-03T16:16:48Z")

</div>

On Wed, Sep 3, 2008 at 5:58 AM, Sijo Kg [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> database without anyof these two in Rails ?Is rails strategy differnet?  
> I did not understand That is why asking Could you please explain with a  
> simple code fragment to how a simple ruby program can be connected to  
> the database I am using postgres And another doubt is if I install dbi  
> will there any conflict with existing rails functionality?
> 
> Thanks in advance  
> Sijo

You can use ActiveRecord without rails. Also, a few other ORM  
projects are out there, one of them being the Sequel gem.

Todd

---

<div class="post-metadata">

**Author:** ![sijo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/da6949/32.png) [@sijo](https://www.ruby-forum.com/u/sijo)\
**Post date:** [September 4, 2008, 9:19am UTC](https://www.ruby-forum.com/t/dtabase-access-with-ruby/147584/4 "2008-09-04T09:19:54Z")

</div>

On Wed, Sep 3, 2008 at 9:17 PM, Sijo Kg [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Could you please points to any links explaining to access Ruby(Not  
> rails) to ActiveRecord
> 
> ## Thanks Sijo
> 
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

Here’s one:  
[http://rails.aizatto.com/2007/05/21/activerecord-without-rails/](http://rails.aizatto.com/2007/05/21/activerecord-without-rails/)

For more, just Google “activerecord without rails”.

Though if you aren’t using Rails, you may want to look at other ORMs:  
I personally like Sequel, but there are other alternatives.

---

<div class="post-metadata">

**Author:** ![sijo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/da6949/32.png) [@sijo](https://www.ruby-forum.com/u/sijo)\
**Post date:** [September 4, 2008, 10:10am UTC](https://www.ruby-forum.com/t/dtabase-access-with-ruby/147584/5 "2008-09-04T10:10:50Z")

</div>

Hi  
Thanks for your reply  
Sijo

---

<div class="post-metadata">

**Author:** ![sijo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/da6949/32.png) [@sijo](https://www.ruby-forum.com/u/sijo)\
**Post date:** [September 4, 2008, 6:22am UTC](https://www.ruby-forum.com/t/dtabase-access-with-ruby/147584/6 "2008-09-04T06:22:54Z")

</div>

Could you please points to any links explaining to access Ruby(Not  
rails) to ActiveRecord

Thanks  
Sijo
