[DB-SIG] comparing with lists via cx_Oracle

Dieter Maurer dieter at handshake.de
Tue Jan 9 19:57:03 CET 2007


Harald Armin Massa wrote at 2007-1-8 19:01 +0100:
>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)",
>dict(pyeles=[1,2,3,4,5]))
>
>obviously does not work.

Does "cx_Oracle" support Python parameter style?

Maybe not. Then use a parameter style supported by "cx_Oracle".


If the problem is not the parameter style, it may be the
sequence --> string conversion. In this case, use can use

	 ",".join([1,2,3,4,5])

instead of "[1,2,3,4,5]".



-- 
Dieter


More information about the DB-SIG mailing list