Re: untrusted languages and non-global superusers? - Mailing list pgsql-general

From Tino Wildenhain
Subject Re: untrusted languages and non-global superusers?
Date
Msg-id 1123148645.15416.26.camel@sabrina.peacock.de
Whole thread Raw
In response to Re: untrusted languages and non-global superusers?  (CSN <cool_screen_name90001@yahoo.com>)
List pgsql-general
Am Donnerstag, den 04.08.2005, 02:24 -0700 schrieb CSN:
>
> --- Tino Wildenhain <tino@wildenhain.de> wrote:
> > > Convenience! I want the email sent whether the
> > member
> > > is added via the web interface, directly in the
> > > database, from the command line, etc. I don't see
> > any
> >
> > Well, I also do such things with a small script
> > which
> > basically LISTENs to notify from database, spools
> > the
> > mails and go sleep again.
>
> Could you elaborate how you do this? IIRC, there's an
> example in the docs using C, but I'd prefer using a
> scripting language.
>

Yes, I'm using a scripting language too:

#!/usr/bin/python
import smtplib, select
from pyPgSQL import PgSQL

db=PgSQL.connect(host=..,user=..,password=..,database=..)

cur=db.cursor()
cur.execute("LISTEN table_where_you_notify")
db.commit()

while True:
    rlist,wlist,xlist=select.select([db.conn.socket],[],[],600)

    if db.conn.socket in rlist:
        db.conn.consumeInput()
        notifies=db.conn.notifies()
        if notifies:
            print "Backend with pid %s used notify" % n.be_pid
            ... here do something interesting, like selecting
            from the spool table and format your mails...

            db.commit()


--
Tino Wildenhain <tino@wildenhain.de>


pgsql-general by date:

Previous
From: CSN
Date:
Subject: Re: untrusted languages and non-global superusers?
Next
From: Havasvölgyi Ottó
Date:
Subject: Re: dbf to pgsql