Update with function

Поиск
Список
Период
Сортировка
От egbert
Тема Update with function
Дата
Msg-id 1333105095.6625.14.camel@para.lan
обсуждение исходный текст
Ответы Re: Update with function  (Adrian Klaver <adrian.klaver@gmail.com>)
Список 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 по дате отправления:

Предыдущее
От: Federico Di Gregorio
Дата:
Сообщение: RELEASE: psycopg 2.4.5
Следующее
От: Adrian Klaver
Дата:
Сообщение: Re: Update with function