我的查询如下所示
result = app._engine.execute ("select bookingid, DATE_FORMAT(bookingdate, '%Y-%m-%d'), DATE_FORMAT(pickupdate, '%Y-%m-%d'), consigneeid, fromcity from booking where consignerid = '{0}'".format(loginid))
当我在MySQL Workbench中运行并返回格式为yyyy-mm-dd的日期时,这个查询有效,但是当我在python flask中运行该查询时,会出现以下错误
^{pr2}$它正在寻找更多的参数,尽管查询中的%用于格式化而不是传递参数。我确实试着寻找原因,但找不到一个好的原因,我做错了什么?在
使用MySQL Connector for Python时,应该转义literal%,这是因为Python使用百分号(%)进行字符串格式设置。在
试试这个:
相关问题 更多 >
编程相关推荐