Sometimes I have to get additional data for a set of ids, the usual select of
select whatever from sometable where id in (1,2,3,4,5)
Next level is, [1,2,3,4,5] is a Collection in Python (List, Tuple, Set)
to transcribe it as
cs.execute("select whatever from sometable where id in (%(pyeles)s)",
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
Carsten Haese wrote:
> On Tue, 2007-01-02 at 15:32 -0600, Carl Karsten wrote:
>> print "#3", cur.execute("select count(*) as ncount from %(table)s",
{'table':'logs'} ) !
>
> Using bound parameters for object names virtually guarantees that your
> code is not portable to other databases.
Not