I am trying to figure out how to pass a list as a parameters through a where statement in SQL, I can not program what I am looking for, but below is what I am looking for.
This is what I would do for one parameter....
x = 1
sql = """Select t1,t2,t3,t4 from database where t1= ? """
cur.execute(sql,x)
Example of what I need
X = [1,2,3,4]
Select t1,t2,t3,t4 from database where t1= 1
Select t1,t2,t3,t4 from database where t1= 2
Select t1,t2,t3,t4 from database where t1= 3
Select t1,t2,t3,t4 from database where t1= 4
Example of what I am trying that isn't working....
X = [1,2,3,4]
sql = """Select Select t1,t2,t3,t4 from database where t1= ? """
example=[]
i = 0
for item in X:
while i < len(x)
row = cur.execute(sql,item)
i +=1
example.append(row)
cur.executemany?"Select Select"... get rid of one of them.whileloop with theicounter is confusing me.cur.execute("SELECT t1, t2, t3, t4 FROM database WHERE t1 IN ({})".format(', '.join(['?' for item in X])), X)