Re: in ARRAY[12, 14, 15, 20]
Giles Velarde <[email protected]>
| Newsgroups | gmane.comp.python.db.psycopg.devel |
|---|---|
| Message-ID | <[email protected]> |
Wow that was a fast response! Following your suggestion I did : since = "2009-06-01" ids = tuple ([12, 14, 15, 20]) query = """ SELECT count(*), organism_id FROM feature WHERE timelastmodified > %s AND organism_id IN %s GROUP BY organism_id; """ import psycopg2.extensions self.cur.execute(query, (since, ids) ) which worked fine. Thanks! Regards, Giles On 17 Nov 2009, at 16:15, Federico Di Gregorio wrote: > Il giorno mar, 17/11/2009 alle 15.42 +0000, Giles Velarde ha scritto: >> I have come accross an odd situation where I am trying to pass pass >> an >> array of IDs into a query: >> >> since = "2009-06-01" >> ids = [12, 14, 15, 20] > > If all you want is an "IN" condition then use a tuple, not a list (I > don't remember if you have to import psycopg2.extensions and > psycopg2.extras to get that behaviour, just do both to be safe.) > > -- > Federico Di Gregorio http://people.initd.org/fog > Debian GNU/Linux Developer [email protected] > INIT.D Developer fog-NGVKUo/i/[email protected] > There's no greys, only white that's got grubby. I'm surprised you > don't know that. And sin, young man, is when you treat people as > things. Including yourself. -- Granny > Weatherwax > _______________________________________________ > Psycopg mailing list > Psycopg-IAPFreCvJWPBWskQ1e/[email protected] > http://lists.initd.org/mailman/listinfo/psycopg -- The Wellcome Trust Sanger Institute is operated by Genome Research Limited, a charity registered in England with number 1021457 and a company registered in England with number 2742969, whose registered office is 215 Euston Road, London, NW1 2BE.