Postgresql: plpython may be removed

Sean Reifschneider jafo at tummy.com
Thu Jun 19 11:53:26 CEST 2003


On Wed, Jun 18, 2003 at 04:58:10PM -0500, Skip Montanaro wrote:
>How so?  I use PostgreSQL from Python and have never heard of plpython.  I
>use psycopg which is well-supported, albeit not by the PostgreSQL folks.

For a simple example of what's being talked about here:

   CREATE OR REPLACE FUNCTION update_resources() RETURNS TRIGGER AS '
      rv = plpy.execute(
                  LongBoringSQLCommandHere,
         1)
      return(None)
      ' LANGUAGE 'plpython';

The above is a very simple example, because all I needed to do was to
run some SQL.  The thing is that you can't just have a regular SQL
function for a trigger action, and basically all I wanted to do was have
an SQL statement run whenever another table was updated.

You can do much more than the above, of course.  Basically, think about
moving some of you psycopg code into the database so that you can call
it as a function.  My use was one table that was the aggregate of
the values in another table, and it made sense to me to just set up a
trigger so that the other table was always up to date without my code
having to do updates in several places.

Sean
-- 
 "Science exists to lend belief to sci-fi movies."
Sean Reifschneider, Inimitably Superfluous <jafo at tummy.com>
tummy.com, ltd. - Linux Consulting since 1995.  Qmail, Python, SysAdmin
      Back off man. I'm a scientist.   http://HackingSociety.org/





More information about the Python-list mailing list