Re: Server side prepared statements and executemany

From: Daniele Varrazzo <daniele(dot)varrazzo(at)gmail(dot)com>
To: Luca Ferroni <luca(at)befair(dot)it>
Cc: "psycopg(at)postgresql(dot)org" <psycopg(at)postgresql(dot)org>
Subject: Re: Server side prepared statements and executemany
Date: 2013-11-15 12:44:23
Message-ID: CA+mi_8Z4Tt0oVkBZr0RqwdXOqTPeTszCdzEZNoasLN5fEt_9TQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: psycopg

On Fri, Nov 15, 2013 at 12:34 PM, Luca Ferroni <luca(at)befair(dot)it> wrote:

> Prepared statements work with query like:
>
> prepare psyco_1 as SELECT * FROM "prova" WHERE "name" = $1
>
> but they raise ProgrammingError (syntaxerror SQL) with the operator IN
>
> prepare psyco_1 as SELECT * FROM "prova" WHERE "name" IN $1

I suspect the () of IN are a syntactic feature and cannot be passed as
a parameter.

Do you want to try to replace the query with "... WHERE name =
any($1)" and pass the parameter as a python list instead of a tuple?
(see also http://initd.org/psycopg/docs/usage.html#adapt-list)

-- Daniele

In response to

Responses

Browse psycopg by date

  From Date Subject
Next Message Federico Di Gregorio 2013-11-15 13:08:46 Re: Server side prepared statements and executemany
Previous Message Luca Ferroni 2013-11-15 12:34:34 Re: Server side prepared statements and executemany