I am trying to create a SQL Query based on the dynamic inputs. It can be single or multiple. However, when I am trying to pass the parameters to the prepared parameters I see that since comma separated values are tuples, it is adding an extra bracket in IN clause. Any idea how to solve it ?
import pyodbc
#engine_ids = 1
engine_ids = 1,2
#platform_ids = 1
platform_ids = 1,2
sql_query = ("select column_A from table where ENGINE IN ({eng_ids}) AND PLATFORM IN({plat_ids})").format(eng_ids=engine_ids, plat_ids=platform_ids)
print(sql_query)
Expected Result - select column_A from table where ENGINE IN (1, 2) AND PLATFORM IN(1, 2)
Actual Result - select column_A from table where ENGINE IN ((1, 2)) AND PLATFORM IN((1, 2))