这里是示例代码
</elevator pitch>
我想动态传递变量名和其他参数。在这里其他参数正确传递,但列名参数我得到错误。因为它用带引号的字符串传递。如何在不带引号的字符串的情况下传递参数,例如下面的示例
order = 10100
status = 'Shipped'
columnname= 'OrderNumber'
sql = """SELECT * from orders where %s = %s and status = %s order by %s"""
df1 = pd.read_sql_query(sql, cnx, params=[columnname,order, status,columnname])
"""SELECT * from orders where 'OrderNumber' = 10100 and status = 'Shipped' order by OrderNumber"""
谢谢