postgres example

Gerhard Häring gh_pythonlist at
Sat Jan 12 15:41:59 EST 2002

Le 12/01/02 à 19:37, QdlatY écrivit:
> Hello!
> Can anybody give me easiest example of using Postgres with Python? This can 
> be exmaple using any of existing Python Postgres support lib.

> Btw. Do i have to root access to install Postgres support lib in Python ? 


If the module uses distutils (at least pyPgSQL does), you can give
options to distutils for installation. The options can be shown with:

    python install --help

Or you can just move the contents of the build/lib.$PLATFORM to a
different directory yourself.

If these contents (only a pyPgSQL directory in the case of pyPgSQL) is
in the same directory as the script that uses the database module,
you're fine, such as in:             # script using pyPgSQL
    pyPgSQL/                # the pyPgSQL directory

If your script and the database module are in different diretories, you
can modify PYTHONPATH in your shell or sys.path in your Python script
such that the datbase module can be imported.

> (Or can i use it without installing?) (There are few libs, i don't
> know wich one is the best for me :/)

Like Mark, I'd suggest pyPgSQL :-)

mail:   gerhard <at> bigfoot <dot> de       registered Linux user #64239
web:    OpenPGP public key id 86AB43C0
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