MySQLDB - generating "...not in (1,2,3)" from Python list ?
Marc Boeren
M.Boeren at guidance.nl
Mon Feb 23 06:12:46 EST 2004
Typo in my snippets:
> cursor.execute("select * from T where C1 not in (%s)", params)
should read
cursor.execute("select * from T where C1 not in %s", params)
since the converter-functions adds the parens already:
> # this is used to translate lists/tuples to (1,2,3) format
> # doesn't check to see if contents are actually numeric...
> def _converter_set_ids(x, d):
> if not len(x): return "(NULL)"
> return "(%s)" % ", ".join([str(xx) for xx in x])
Cheerio, Marc.
More information about the Python-list
mailing list