I am having issues looping a list of values that has ids
to pass them as parameters into a SQL query using pyodbc connection. I read this post
which seems to have lot good information, but I haven't seen an answer that loops through the list and replaces ids
in each iteration.
Here is my list,
Allids = [201,202,203,204,205,206,207]
I would like to do something like this,
for i in Allids:
cu.execute('select my_var1, my_var2, my_var2 from testdata.dbo.tbl where id = 'i'')
I get an error saying that ][SQL Server]Conversion failed when converting the varchar value 'i' to data type int.
Is it possible do this way? or convert the list into tuples and follow different methods? Any ideas would be appreciated. Thanks in advance!