# Postgres/Postgres-pr - some confusion

**URL:** <https://rubytalk.org/t/postgres-postgres-pr-some-confusion/32982>\
**Category:** ruby-talk\
**Created:** [16 November 2006 09:51 UTC](https://rubytalk.org/t/postgres-postgres-pr-some-confusion/32982 "2006-11-16T09:51:54Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nick\_Black](https://avatars.discourse-cdn.com/v4/letter/n/e9a140/32.png) [@Nick\_Black](https://rubytalk.org/u/Nick_Black)\
**Post date:** [16 November 2006 09:51 UTC](https://rubytalk.org/t/postgres-postgres-pr-some-confusion/32982/1 "2006-11-16T09:51:54Z")

</div>

Hello,

I'm doing some work using the ruby postgres lirbaries and I'm slightly  
confused about a few things. I installed the postgres libraries  
using:

gem install postgres posrgres-pr

If I use:

require 'rubygems'  
require 'postgres-pr/connection'

I cannot use the following syntax:

&nbsp;&nbsp;db = PGconn.connect($HOST, "", "", "", $DBNAME , $LOGIN, $PASS)

Where as when I use:

require 'rubygems'  
require 'postgres'

This syntax is fine. So there is obviously a difference between the  
two libraries, but I'm kind of stuck for finding out exactly what the  
differences are. I need

Based on this documentation:

[http://phrogz.net/rubylibs/rdoc/index.html](http://phrogz.net/rubylibs/rdoc/index.html)

and the docs from my local gems directory, I've got some things  
working. But, when I try and the the PGConn.quote method, ruby  
complains that there is no quote method, which according to the source  
code I can find, there isnt, but which is listed in the documentation.  
So I'm wondering if the documentation I have been looking at is  
incorrect, if I am missing some libraries, or if I am not requiring  
the correct libraries. I thought that the postgres-pr library was a  
wrapper for the postgres.c library?

Any explanation / direction to documenation would be really  
appreciated. Even just confirming if there is a PGconn.quote method  
and which lirbary its in would be a great help!

CHeers

Nick

---

<div class="post-metadata">

**Author:** ![Jeremy\_Kemper1](https://avatars.discourse-cdn.com/v4/letter/j/c6cbf5/32.png) [@Jeremy\_Kemper1](https://rubytalk.org/u/Jeremy_Kemper1)\
**Post date:** [16 November 2006 18:46 UTC](https://rubytalk.org/t/postgres-postgres-pr-some-confusion/32982/2 "2006-11-16T18:46:38Z")

</div>

postgres-pr is a pure-Ruby postgres client; postgres is a C client using  
libpq.

jeremy

> **···**
>
> On 11/16/06, Nick Black \<nickblack1@gmail.com\> wrote:
> 
> > I'm doing some work using the ruby postgres lirbaries and I'm slightly  
> > confused about a few things. I installed the postgres libraries  
> > using:

---

<div class="post-metadata">

**Author:** ![Andrew\_Stone](https://avatars.discourse-cdn.com/v4/letter/a/b9bd4f/32.png) [@Andrew\_Stone](https://rubytalk.org/u/Andrew_Stone)\
**Post date:** [16 November 2006 18:52 UTC](https://rubytalk.org/t/postgres-postgres-pr-some-confusion/32982/3 "2006-11-16T18:52:02Z")

</div>

> the correct libraries. I thought that the postgres-pr library was a  
> wrapper for the postgres.c library?

I thought the same thing until I was writing some basic queries using the  
connection and pgresult. The result type is different between the two.  
I've moved away from using postgres-pr because of the inconsistencies and  
belief that the c client will be faster anyway.

> **···**
>
> --  
> Andrew Stone

---

<div class="post-metadata">

**Author:** ![Kashia\_Buch](https://avatars.discourse-cdn.com/v4/letter/k/f05b48/32.png) [@Kashia\_Buch](https://rubytalk.org/u/Kashia_Buch)\
**Post date:** [16 November 2006 20:01 UTC](https://rubytalk.org/t/postgres-postgres-pr-some-confusion/32982/4 "2006-11-16T20:01:14Z")

</div>

Hi,

> > orking. But, when I try and the the PGConn.quote method, ruby

PGconn.escape(str) should be available.

> > the correct libraries. I thought that the postgres-pr library was a  
> > wrapper for the postgres.c library?
> 
> I thought the same thing until I was writing some basic queries using the  
> connection and pgresult. The result type is different between the two.  
> I've moved away from using postgres-pr because of the inconsistencies and  
> belief that the c client will be faster anyway.

Yes, the c extension is much better, not perfect though.

When you have a look at Og (get 0.40 via rubygems), you'll see that a few  
things have to be done to make the -pr more compatible to the c ext.

og/lib/og/adapter/postgresql/override.rb

I think it was Neumann who made the postgres-pr wrapper, which is a thin  
layer around the dbi lib as far as I remember, it is pure Ruby, no C  
involved.

Kash

> **···**
>
> --  
> Using Opera's revolutionary e-mail client: [Opera Web Browser | Faster, Safer, Smarter | Opera](http://www.opera.com/mail/)
