Re: how to pass in bind variables with cursor.copy_expert?

Поиск
Список
Период
Сортировка
От Federico Di Gregorio
Тема Re: how to pass in bind variables with cursor.copy_expert?
Дата
Msg-id 53078306.106@dndg.it
обсуждение исходный текст
Ответ на how to pass in bind variables with cursor.copy_expert?  ("W. Matthew Wilson" <matt@tplus1.com>)
Ответы Re: how to pass in bind variables with cursor.copy_expert?  (Adrian Klaver <adrian.klaver@aklaver.com>)
Список psycopg
On 21/02/2014 17:27, W. Matthew Wilson wrote:
> I need to extract some rows from a table as a CSV file, based on a
> query sort of like:
>
>     copy (
>         select *
>         from blah
>         where x = %(x)s
>     )
>
> but I don't see how to pass in a dictionary with values for the query!

You can use cursor.mogrify() to build the query and then pass it to
cursor.copy_export(). See the documentation for the details.

federico

--
Federico Di Gregorio                         federico.digregorio@dndg.it
Di Nunzio & Di Gregorio srl                               http://dndg.it
 Everything will be OK at the end. If it's not OK, it's not the end.
                                                              -- Unknown


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

Предыдущее
От: "W. Matthew Wilson"
Дата:
Сообщение: how to pass in bind variables with cursor.copy_expert?
Следующее
От: Adrian Klaver
Дата:
Сообщение: Re: how to pass in bind variables with cursor.copy_expert?