can't connect to postgresql using pygresql

Gerhard Häring gerhard.nospam at
Wed Sep 12 01:20:26 CEST 2001

On 11 Sep 2001 10:58:07 -0700, rdack <rdacker at> wrote:
>using pygresql-3.2, postgresql-7.1.3, mac os x 10.0?, g4
>i can import _pg, but get error on connect:

For PyGreSQL:
_pg is the low-level interface, don't use this
pg is the PyGreSQL proprietary interface, so IMHO should be avoided
pgdb is the DB-API 2 interface

For PyPgSQL, which I'd recommend:
pq is the low-level interface, you shouldn't use this directly
PgSQL is the DB-API 2 interface

So, then, the following should work (of course normally you will want to create
your own database user and database => createuser and createdb):

Python 2.1.1 (#1, Sep  8 2001, 02:43:26)
[GCC 2.95.3 20010315 (SuSE)] on linux2
Type "copyright", "credits" or "license" for more information.
>>> import PgSQL        # PyPgSQL
>>> con = PgSQL.connect(database = "template1")
>>> con
<PgSQL.Connection instance at 0x816696c>
>>> import pgdb         # PyGreSQL
>>> con2 = pgdb.connect(database = "template1")
>>> con2
<pgdb.pgdbCnx instance at 0x81532fc>

mail:   gerhard <at> bigfoot <dot> de       registered Linux user #64239
web:    public key at homepage
public key fingerprint: DEC1 1D02 5743 1159 CD20  A4B6 7B22 6575 86AB 43C0
reduce(lambda x,y:x+y,map(lambda x:chr(ord(x)^42),tuple('zS^BED\nX_FOY\x0b')))

More information about the Python-list mailing list