I mean something like this:
from django.db import connection
cursor=connection.cursor()
cursor.execute('SELECT * FROM mytable where id IN (%s)', [params])
Parameters can not be just iterable - it doesn't work. Cannot be also in CSV format due escaping value by db handler.
How to use placeholder within IN
?
By CSV is wrong, I mean that for params=['1','2','3','4','5']
c.execute('select * from mytable where id in (%s)', [','.join(params)])
will produce:
select * from mytable where id in ('1,2,3,4,5')
but correct sql is:
select * from mytable where id in (1,2,3,4,5)
and it seems to be hard to achieve with placeholders.