I have an SQL update query with IN statement which is executed via SQLAlchemy. Unfortunately current implementation uses string interpolation, which I'd like to replace with more secure option.
session.execute('''
UPDATE servers SET
cpu_cores=st.cpu_cores,
cpu_mhz=st.cpu_mhz,
ram_mb=st.ram_mb
FROM servers
WHERE
server.provider_id IN (%s)
''' % ','.join([ ... ]))
Is it possible to replace % operator with in_ method here? Or I should re-implement this query using session.query?