SearchWiki:
  12 User(s) Active on Site
  232 Wiki Pages

Most Recently Modified

Meeting Schedules

Club Resources (edit)

How This Wiki Works

Meeting space complements of:
Computer books
            and technical books at discount prices
Check them out; they are a great source of technical books at very good prices!

If you have shopped at Nerdbooks.com, help them out by reviewing them at ResellerRatings.com. You will need your invoice number to prove you are a real customer, and not just ballot stuffing.
Recent Changes Printable View Page History Edit Page
Content Last Modified on November 12, 2005, at 04:25 AM CST

Installing the 'psycopg' Database Adapter

'psycopg' is a database adapter for talking to PostgreSQL from the Python language. It is not related to Zope in any way. It implements the DB-API 2.0 that is standard in the Python community.

There are two major versions of 'psycopg', version 1 and version 2.

Psycopg1 is stable and refined, but difficult to install, as we'll see here. Use this major version with Zope 3, not Psycopg2. Version 2 is still in beta development and is NOT supported for use with Zope 3.

Note that you may install both versions 1 and 2, as they have different Python package names ("import psycopg" versus "import psycopg2"). Version 2 is more advanced but not well supported yet.


Installing 'psycopg' v1

Grab an official tarball:

  [jrush]# cd /var/tmp
  [jrush]# wget http://initd.org/pub/software/psycopg/psycopg-1.1.21.tar.gz
  [jrush]# tar xvzf psycopg-1.1.21.tar.gz
  [jrush]# cd psycopg-1.1.21

or check out the latest version from their Subversion source repository.

  [jrush]# cd /var/tmp
  [jrush]# svn co http://initd.org/svn/psycopg/psycopg1/trunk psycopg1
  [jrush]# cd psycopg1

Now build and install the package. You'll have to choose whether to build it for Python 2.3 or 2.4 or both. Also needed is the location of the PostgreSQL includes directory and of the mxDateTime add-on module.

  [jrush]# ./configure \
             --with-python-version=2.4 \
             --prefix=/usr \
             --with-python=/usr/bin/python2.4 \
             --with-postgres-includes=/usr/include/pgsql \
             --with-mxdatetime-includes=/usr/lib/python2.4/site-packages/mx/DateTime/mxDateTime/
  [jrush]# make
  [jrush]# sudo make install

Now test your installation:

  [jrush]# python2.4
  >>> import psycopg
  >>>

Installing 'psycopg' v2

Grab an official tarball:

  [jrush]# cd /var/tmp
  [jrush]# wget http://initd.org/pub/software/psycopg/psycopg2-2.0b5.tar.gz
  [jrush]# tar xvzf psycopg2-2.0b5.tar.gz
  [jrush]# cd psycopg2-2.0b5

Now build and install the package. You'll have to choose whether to build it for Python 2.3 or 2.4 or both. Note that the mxDateTime package is no longer required for 'psycopg' v2.

  [jrush]# python2.3 setup.py build
  [jrush]# sudo python2.4 setup.py install

Now test your installation:

  [jrush]# python2.4
  >>> import psycopg2
  >>>
Recent Changes Printable View Page History Edit Page