postgresql triggers to update GUI?

Gerhard Häring gh_pythonlist at gmx.de
Tue Nov 27 05:35:26 CET 2001


On Mon, Nov 26, 2001 at 02:52:39PM -0500, Robert Nikander wrote:
> Hi,
> 
> I am writing a python program that uses a postgresql db backend.  I would
> like to update the gui whenever a change in certain tables occurs, so it
> would be nice to use triggers rather than generating the 'events' when I
> update the db.  That way I get cascading changes.  Does anyone know of a
> python module that supports postresql triggers? ie: you can create a
> trigger that calls a python function?  Is there another solution here
> that I am missing?

Hmm. I think you could use PostgreSQL's notification mechanism for this.
pyPgSQL does support PostgreSQL notifications (look into the demo2a.py and
demo2b.py files in the examples/ directory). The URL is http://pypgsql.sf.net/

I think you could have your trigger send a PostgreSQL notification and have the
client side select.poll() or select.select() for the notification. The above
mentioned examples show how to do this.

Gerhard
-- 
mail:   gerhard <at> bigfoot <dot> de       registered Linux user #64239
web:    http://www.cs.fhm.edu/~ifw00065/    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