Getting the Skunk working with PostgreSQL 7.4.2

Andreas Kaempf <[email protected]>
Newsgroups gmane.comp.web.skunkweb
Organization Soundience, Ltd.
Message-ID <[email protected]>
I had some troubles getting PostreSQL 7.4.2 working with PyDO and
SkunkWeb, and would like to share the solutions I found, in case anyone
else is having similar problems. Note that my experience was under
Gentoo Linux; other distributions may be different. Gentoo does not seem
to have an e-build for this yet.

Basically, the issue is that the pgdb Python interface to PostgreSQL no
longer ships with PostgreSQL, and obtaining and installing this module 
are not entirely obvious.

Assuming you have PostreSQL installed, you need to download the Python
interface from http://www.pygresql.org (the latest version is currently
3.4)

Extract it to a working directory, enter that directory, and type:
python setup.py build

If you get compiler errors (I did) indicating that postgres.h could not
be found, find where postgres.h is located on your system (e.g., locate
postgres.h), and edit setup setup.py to add this directory to the list
of include directories (line 33 of setup.py). In my installation, I had
to add /usr/include/postgresql/server to the list.

If everything compiles fine, install it typing the following as root:
python setup.py install

Test it by starting Python and typing:
import pgdb

If you get an error message that the module could not be found (again,
this happened to me), check the permissions for _pg.so, if necessary
changing them by typing:
chmod 755 /usr/lib/python2.3/site-packages/_pg.so

Try importing the module again, hopefully it now works.

One other thing: In postgres, you need to enable internet connection, 
since this is what pgdb uses to connect with the server. You may need
to add -i to startup string in your /etc/init.d/postgresql (for Gentoo, 
edit /etc/conf.d/postgresql, but add only -i not other parameters that
are commented out, unless your kernel is compiled with ipv6, which is
required for the other parameters in the commented-out string).

The PyDO connection string that worked for me is (where 'mydb' is the
name of my database, and 'myname' is the user name):
PyDO2.DBIInitAlias('mydb', 'pydo:postgresql:localhost:mydb:myname')

And finally, I believe you have to do commit() on each database
object to save any changes (not sure about this, again, comments
welcome).

Before finding pgdb, I tried to get some of the other drivers to
work without success; if anyone could document their operation and
merits relative to pgdb, that would be great.

Cheers,
Andreas



-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.