I have a python list, say l
l = [1,5,8]
I want to write a sql query to get the data for all the elements of the list, say
s
For example, if you want the sql query:
select name from studens where id in (1, 5, 8)
What about:
my_list = [1, 5, 8] cur.execute("select name from studens where id in %s" % repr(my_list).replace('[','(').replace(']',')') )