Openquery in python- How to pass a list of strings in python as "in" clause (filter) in Openquery

Viewed 17

I have a list of strings that i want to use as a filter in sql query using Openquery. I am using the following

z=['12_47','34_98']
z1=['\'\'{}\'\''.format(x) for x in z] # to convert single quote to double single quote for open query
z1=tuple(z1)
placeholder='?'

placeholders=', '.join(placeholder for used in z1)

sql=f"""select * from openquery(FR,'select * from database where data in ({placeholders})')"""

The problem is z1 there comes out to be

["''12_47''","''34_98''"]

which inturn is not making my sql query to work .How can i just get this

[''12_47'',''34_98'']
0 Answers
Related