SearchWiki:
  4 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 October 26, 2005, at 05:43 PM CST

Setting Up Client Access from Python to a PostgreSQL Database

There are several layers to peel regarding setting up access to a PostgreSQL database from the Python programming language.

  1. First and foremost, install or obtain access rights to a PostgreSQL server. We use the 8.0 family here. We won't cover the steps to do this as it isn't Python-specific. The dfwPython server runs a PostgreSQL server that is available for club projects. Access information is as follows:

    host=python.taupro.com user=XXX password=YYY dbname=ZZZ

    The server only accepts SSL-encrypted connections from outside the club host, or plaintext connections from applications running on the club host coming in via 'localhost'.
  2. Next install the PostgreSQL client software on your PC. Again this is not Python-related and differs between operating system and software distribution.
  3. Now we need a Python extension module that lets us invoke database operations from within Python. A popular one we use is named 'psycopg'. One item to note is that there are two major versions, v1.x and v2.x, with different APIs.
    1. Psycopg1 is stable and refined, but difficult to install, as we'll see here. Use this major version with Zope 3, not Psycopg2.
      1. The first installation hurdle is that Psycopg1 uses an external package 'mxDateTime' that must be installed first, to represent the SQL 'datetime' type.
      2. You can grab an official tarball: cd /var/tmp wget http://initd.org/pub/software/psycopg/psycopg-1.1.21.tar.gz tar xvzf psycopg-1.1.21.tar.gz cd psycopg-1.1.21 or check out the latest version from their Subversion source repository. cd /var/tmp svn co http://initd.org/svn/psycopg/psycopg1/trunk psycopg1 cd psycopg1
    2. Psycopg2 is a near-total rewrite

a complete rewrite of the original code to provide new-style classes for connection and cursor objects, and ...

 and is still in beta.  It p
Recent Changes Printable View Page History Edit Page