import pandas as pd
q = """
select *
from tbl
where metric = %(my_metric)s
;
"""
params = {'my_metric':'sales'}
pd.read_sql(q, mysql_conn, params=params)
Im using pandas read_sql function to safely pass arguments to my query string. I would like to return the final query string with the arguments replaced as well as the results. So for example, return the string:
select *
from tbl
where metric = 'sales'
;
Any way to do this?