From: | Federico Di Gregorio <fog(at)dndg(dot)it> |
---|---|
To: | psycopg(at)postgresql(dot)org |
Subject: | Re: Server side prepared statements and executemany |
Date: | 2013-11-15 13:08:46 |
Message-ID: | 52861CDE.7010601@dndg.it |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | psycopg |
On 15/11/2013 13:34, Luca Ferroni wrote:
> you are right, here is the example. In writing it I noticed an
> interesting behaviour.
> 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
IN has always had problems, not just when used thorugh psycopg. My
suggestion is to substitute it with ANY:
prepare psyco_1 as SELECT * FROM "prova" WHERE "name" = ANY($1).
Note that $1 should be an array (but isn't a problem when using psycopg,
just pass a list).
federico
--
Federico Di Gregorio federico(dot)digregorio(at)dndg(dot)it
Di Nunzio & Di Gregorio srl http://dndg.it
If a process is potentially good, but 90%+ of the time smart and
well-intentioned people screw it up, then it's a bad process.
-- Steve Yegge
From | Date | Subject | |
---|---|---|---|
Next Message | Joe Abbate | 2013-11-15 13:26:43 | Re: Server side prepared statements and executemany |
Previous Message | Daniele Varrazzo | 2013-11-15 12:44:23 | Re: Server side prepared statements and executemany |