# Ruby + Postgresql

**URL:** <https://www.ruby-forum.com/t/ruby-postgresql/63306>\
**Category:** Ruby\
**Created:** [June 14, 2006, 2:18am UTC](https://www.ruby-forum.com/t/ruby-postgresql/63306 "2006-06-14T02:18:04Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![tma](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ed655f/32.png) [@tma](https://www.ruby-forum.com/u/tma)\
**Post date:** [June 14, 2006, 2:18am UTC](https://www.ruby-forum.com/t/ruby-postgresql/63306/1 "2006-06-14T02:18:04Z")

</div>

First, I installed DBD/DBI for my Debian box and I’m not finding  
anything that looks like ri docs. I haven’t any idea what to do about  
this and am hoping that maybe it will just go away for now. I doubt it  
will.

I don’t know if this is a Debian problem or what. So I’m putting it  
aside for now.

What I would like to know is how to connect to a postgres database  
that’s located on a TCP/IP connection (on another machine). So far, the  
docs I can find are a little vague on this department or are all about  
MySQL which doesn’t really help.

---

<div class="post-metadata">

**Author:** ![tma](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ed655f/32.png) [@tma](https://www.ruby-forum.com/u/tma)\
**Post date:** [June 14, 2006, 12:16pm UTC](https://www.ruby-forum.com/t/ruby-postgresql/63306/2 "2006-06-14T12:16:50Z")

</div>

Tom A. wrote:

> First, I installed DBD/DBI for my Debian box and I’m not finding  
> anything that looks like ri docs. I haven’t any idea what to do about  
> this and am hoping that maybe it will just go away for now. I doubt it  
> will.
> 
> I don’t know if this is a Debian problem or what. So I’m putting it  
> aside for now.

It is a Debian annoyance, the output of ‘aptitude show ruby1.8’ states  
clearly:

On Debian, Ruby 1.8 is provided as separate packages. You can get  
full Ruby 1.8 distribution by installing following packages.

ruby1.8 ruby1.8-dev ri1.8 rdoc1.8 irb1.8 ruby1.8-elisp  
ruby1.8-examples libdbm-ruby1.8 libgdbm-ruby1.8 libtcltk-ruby1.8  
libopenssl-ruby1.8 libreadline-ruby1.8

This information can be found on various sites, and even with  
searching the mailing list archives for ‘debian’ and ‘ruby’.

Other packages you might want to install are

libdbi-ruby1.8  
libdbd-pg-ruby1.8

> What I would like to know is how to connect to a postgres database  
> that’s located on a TCP/IP connection (on another machine). So far, the  
> docs I can find are a little vague on this department or are all about  
> MySQL which doesn’t really help.

It’s only about replacing ‘MySQL’ with ‘Pg’:

dbh = DBI.connect(‘DBI:Pg:test:hostname’, ‘user’, ‘password’)

alternatively

dbh = DBI.connect(‘DBI:Pg:database=test;host=hostname’,  
‘user’,‘password’)

HTH,

t.

---

<div class="post-metadata">

**Author:** ![tma](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ed655f/32.png) [@tma](https://www.ruby-forum.com/u/tma)\
**Post date:** [June 14, 2006, 2:52pm UTC](https://www.ruby-forum.com/t/ruby-postgresql/63306/3 "2006-06-14T14:52:43Z")

</div>

Thank you very much.  
I didn’t even know I could to an ‘aptitude show…’.

Wow, the things I learn…
