Update with function - Mailing list psycopg

From egbert
Subject Update with function
Date
Msg-id 1333105095.6625.14.camel@para.lan
Whole thread Raw
Responses Re: Update with function  (Adrian Klaver <adrian.klaver@gmail.com>)
List psycopg
Hello,
I am new to this list, and a fairly unsophisticated user of postgresql
and psycopg.

I try to update one field in all records of a table.
The new value is too complicated for a simple expression, so I thought
about a python function. That function uses another field, recno, from
each record.
My question is: how do I pass that second field to the function.

The relevant parts of my script are now:

define makeyear(nummer):
    # ...
    return value

cur.execute("update books set inyear=%s", (makeyear(recno),))

The error message says that recno is not defined.
egbert
--
Egbert Bouwman
Keizersgracht 197-II
1016 DS  Amsterdam
Tel 0(031)20 6257991


psycopg by date:

Previous
From: Federico Di Gregorio
Date:
Subject: RELEASE: psycopg 2.4.5
Next
From: Adrian Klaver
Date:
Subject: Re: Update with function