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

From: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
To: "W(dot) Matthew Wilson" <matt(at)tplus1(dot)com>, "psycopg(at)postgresql(dot)org" <psycopg(at)postgresql(dot)org>
Subject: Re: how to pass in bind variables with cursor.copy_expert?
Date: 2014-02-21 19:01:00
Message-ID: 5307A26C.2050807@aklaver.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: psycopg

On 02/21/2014 08:27 AM, 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!
>
> Is this not allowed?
>
> What am I missing?

Now I see what I was missing. I did not read the subject fully and see
you wanted to use copy_expert. In that situation, I do as Federico
suggested and build the full query first then pass it to copy_expert.

>
> Thanks in advance.
>
> Matt
>

In response to

Browse psycopg by date

  From Date Subject
Next Message Ari King 2014-03-13 21:40:52 Fwd: Timestamp Query Parameters
Previous Message Adrian Klaver 2014-02-21 18:54:05 Re: how to pass in bind variables with cursor.copy_expert?