Re: Encountered an error

Поиск
Список
Период
Сортировка
От Daniele Varrazzo
Тема Re: Encountered an error
Дата
Msg-id CA+mi_8aCZO=irYnPrUfTTTHFXPhqcJEhNp4E7iB84KAUKKbKHA@mail.gmail.com
обсуждение исходный текст
Ответ на Encountered an error  (Shaan Repswal <shaun.reapswaal@gmail.com>)
Список psycopg
On Thu, Mar 10, 2016 at 5:37 AM, Shaan Repswal
<shaun.reapswaal@gmail.com> wrote:
>                 #First make the appropriate column
>                 cur.execute("""ALTER TABLE inventory
>                             ADD %s integer DEFAULT NULL;""",
> [x[0].get_text()])
>                 #Then give that column the appropriate value for the current
> record
>                 cur.execute("""UPDATE inventory
>                             SET %s = %s
>                             WHERE name = %s;""", [x[0].get_text(),
> x[1].get_text(), self.entry_product_name.get_text()])

You cannot use %s to pass a table or field name: %s is only used for the values.

There is still no support for escaping values into identifier names.
There is something in the current master: the function
psycopg2.extensions.quote_ident(), but it hasn't been released yet and
the interface may change before the release.

-- Daniele


В списке psycopg по дате отправления:

Предыдущее
От: Shaan Repswal
Дата:
Сообщение: Encountered an error
Следующее
От: Adrian Klaver
Дата:
Сообщение: Re: Encountered an error