Re: untrusted languages and non-global superusers?

From: Tino Wildenhain <tino(at)wildenhain(dot)de>
To: CSN <cool_screen_name90001(at)yahoo(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: untrusted languages and non-global superusers?
Date: 2005-08-04 09:44:05
Message-ID: 1123148645.15416.26.camel@sabrina.peacock.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Am Donnerstag, den 04.08.2005, 02:24 -0700 schrieb CSN:
>
> --- Tino Wildenhain <tino(at)wildenhain(dot)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(at)wildenhain(dot)de>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Havasvölgyi Ottó 2005-08-04 10:37:21 Re: dbf to pgsql
Previous Message Tan Chen Yee 2005-08-04 09:26:30 Restore PLAIN file