[PyGreSQL] Pygresql and triggers

Daryl Tester dt at picknowl.com.au
Wed Apr 5 09:40:19 EDT 2000


Jerome Alet wrote:

> I think the purpose of PostgreSQL's listen and notify statements both
> exist just to solve this sort of problem. Am I wrong ?

No, you're not wrong; I was.  But you've probably seen my subsequent
post on this.  :-)

> Are this statements supported by PygreSQL ?

After some digging through the source (because I now knew the libpq
function to look for), the answer is yes.  In 2.4 there is a getnotify()
method on the connection:

--- Window 1 ---
>>> import pg
>>> db = pg.connect('test')
>>> db.query('listen foo')     # This is important, and the README says so.

--- Window 2 ---
$ psql test
test=> notify foo;
NOTIFY

--- Window 1 ---
>>> print db.getnotify()
('foo', 5714)

The connection even has a fileno() method to return the socket
descriptor, so that it can be incorporated into a select() loop.
I love it when a solution presents itself just by redefining the
problem.

Love your work, D'Arcy.  :-)


Regards,
  Daryl Tester




More information about the PyGreSQL mailing list