[DB-SIG] comparing with lists via cx_Oracle

Federico Di Gregorio fog at initd.org
Mon Jan 8 19:47:56 CET 2007


Il giorno lun, 08/01/2007 alle 19.01 +0100, Harald Armin Massa ha
scritto:
> within PostgreSQL and psycopg2 I can write:
> 
> cs.execute("""select name from kundentable
>                    where id_p = any(%(ids)s)""",
>                   dict(ids=[8718, 27339, 108509463, 9113, 14951]))
> 
> which gets translated to
> cs.query
> 'select name from kundentable
>  where id_p = any(ARRAY[8718, 27339, 108509463, 9113, 14951])' 

Completely off-topic but in psycopg2 you can do even better if you
import psycopg2.extras and then use a tuple. It will get adapted into
the right parenthesized form for SQL IN operator.

federico

-- 
Federico Di Gregorio                         http://people.initd.org/fog
Debian GNU/Linux Developer                                fog at debian.org
INIT.D Developer                                           fog at initd.org
             I'm hung like Einstein and smart as a horse! -- Trottalemme
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Questa =?ISO-8859-1?Q?=E8?= una parte del messaggio
	firmata digitalmente
Url : http://mail.python.org/pipermail/db-sig/attachments/20070108/e9504dd7/attachment.pgp 


More information about the DB-SIG mailing list