MySQLDB - generating "...not in (1,2,3)" from Python list ?

Peter Otten __peter__ at web.de
Mon Feb 23 05:01:41 EST 2004


Richard Shea wrote:

> So in summary - would anyone be kind enough to tell me, given that I'm
> using scanf style SQL subbing, how I can substitute in a comma
> delimited list of integers without quotes being put around things to
> upset the SQL ?

>>> numbers = (1,2,3,99)
>>> "(%s)" % ", ".join(map(str, numbers))
'(1, 2, 3, 99)'





More information about the Python-list mailing list