correct parameter usage for "select * where id in ..."
saniac
saniac at gmail.com
Sat Oct 28 16:27:12 EDT 2006
paul wrote:
> Frank Millman schrieb:
> > If you want it to handle a variable number of values, you will have to
> > programmatically construct the sql statement with the appropriate
> > number of parameters.
Yes, I should have made it clear it was the variable part that was
hard.
> >>> vals = (1,2,3,4,5)
> >>> sql = "select * from table where value in ("+','.join("?"*len(vals))+")"
> >>> print sql
> 'select * from table where value in (?,?,?,?,?)'
Argh, I have a scripting language and I'm not building up strings
dynamically? What an idiot.
Thanks, that's just what I needed.
More information about the Python-list
mailing list