| From: | egbert <egbert(dot)bouwman(at)xs4all(dot)nl> |
|---|---|
| To: | psycopg(at)postgresql(dot)org |
| Subject: | Update with function |
| Date: | 2012-03-30 10:58:15 |
| Message-ID: | 1333105095.6625.14.camel@para.lan |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | 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
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Adrian Klaver | 2012-03-30 13:45:35 | Re: Update with function |
| Previous Message | Federico Di Gregorio | 2012-03-28 21:30:23 | RELEASE: psycopg 2.4.5 |