I try to use in-query in python. But I got different exceptions about it.
First try is:
query = """select keyword
from keyword
where keyword in %(ids)s and country = %(country)s"""
cursor.execute(query, {'ids': tuple(ids), 'country': country})
It gives error like: Failed processing pyformat-parameters; Python 'tuple' cannot be converted to a MySQL type
Second try is:
str_keywords = ",".join(tuple("'" + str(i) + "'" for i in ids))
query = """select keyword
from keyword
where keyword in (%s) and country = %s"""
cursor.execute(query, (str_keywords, country))
This doesn't give error but it doesn’t work.
Any suggestion?