Suppose a simple query in python as follows. The python code reads a "new city" from a user. The question is how to update the query by appending a list of cities (e.g., 'city1', 'city2', 'city3') to the where clause in the query.
mycursor = mydb.cursor()
sql = "select * FROM my_table
WHERE (city = 'Seattle')
or (city = 'Portland')"
mycursor.execute(sql)
mydb.commit()
desired sql script
mycursor = mydb.cursor()
sql = "select * FROM my_table
WHERE (city = 'Seattle')
or (city = 'Portland')
or (city = 'city1')
or (city = 'city2)
or (city ='city3')"
mycursor.execute(sql)
mydb.commit()
WHERE city IN ('Seattle', 'Portland', ...)?