I have a MySQL query that is stored in a python string. It looks like this;
query = """ SELECT colA, colB
FROM table WHERE colC = '1' """
Suppose I want to insert string variable to construct the same query
.
Can I do something similar to this?
Var1 = 'colA'
Var2 = 'colB'
query = """ SELECT %s, %s
FROM table WHERE colC = '1' """, Var1, Var2
How can I do this in python? I am using Python 2.7