I have a list l= ['A','B','C'...]
which has a dynamic number of elements. I want to run the below statement in using SQL via Python.
sqlstr = "select * from [table] where ID in (%s) and column2=?"
sqlstr = sqlstr % ','.join('?' * len(l))
However, when I try to run
pd.read_sql(sqlstr,conn,params=[l,parameter2])
There is an error
The SQL contains 4 parameter markers, but 2 parameter supplied
I understand why there is an error because the list is parsed as 1 single parameter rather than individually. But I don't know how to fix it.