Search Postgresql Archives

Re: untrusted languages and non-global superusers?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Am Donnerstag, den 04.08.2005, 02:24 -0700 schrieb CSN:
> 
> --- Tino Wildenhain <tino@xxxxxxxxxxxxx> 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@xxxxxxxxxxxxx>


---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
       choose an index scan if your joining column's datatypes do not
       match

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux