Joerg,

> maybe this is obvious, but I don't know how to execute a query like:
> select * from mytable where id in (1,2,3)
> from python. The difficult part is the set in the where clause, the "in
> (a,b,c,d, ...)"


WHICH database are you talking about?

With Oracle, you are on your own, that is, you have to do stringmagic
to create the SQL.

With PostgreSQL and PSYCOPG2 you can use lists:

cs.execute("select * from s2e where element = any (%(what)s)",
dict(what=[1,2,3]))

using PostgreSQL arrays and the "any" function.

Best wishes,

Harald


-- 
GHUM Harald Massa
persuadere et programmare
Harald Armin Massa
Spielberger Straße 49
70435 Stuttgart
0173/9409607
fx 01212-5-13695179
-
EuroPython 2008 will take place in Vilnius, Lithuania - Stay tuned!
_______________________________________________
DB-SIG maillist  -  DB-SIG@python.org
http://mail.python.org/mailman/listinfo/db-sig

Reply via email to