If you are on Python 3.6 or higher, you can even use f-strings:

query= f'SELECT * FROM dbsnp where rs_id={rs_id} where {key}="abc"'