Re: untrusted languages and non-global superusers?
От | Tino Wildenhain |
---|---|
Тема | Re: untrusted languages and non-global superusers? |
Дата | |
Msg-id | 1123148645.15416.26.camel@sabrina.peacock.de обсуждение исходный текст |
Ответ на | Re: untrusted languages and non-global superusers? (CSN <cool_screen_name90001@yahoo.com>) |
Список | 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 по дате отправления: