报错解决: pymysql.err.OperationalError: (1054, "Unknown column 'LO20220907000000010' in 'where clause'
代码如下:
platformOrderNo = result['data']['platformOrderNo'] # platformOrderNo=LO20220829000000036 exe_sql = f"select * from repay_plan WHERE loan_order_no={platformOrderNo}" db_res = self.client.mysql.exec_sql_query(exe_sql) print(db_res)
报错:
data = b"\xff\x1e\x04#42S22Unknown column 'LO20220907000000010' in 'where clause'" def raise_mysql_exception(data): errno = struct.unpack("<h", data[1:3])[0] errval = data[9:].decode("utf-8", "replace") errorclass = error_map.get(errno) if errorclass is None: errorclass = InternalError if errno < 1000 else OperationalError > raise errorclass(errno, errval) E pymysql.err.OperationalError: (1054, "Unknown column 'LO20220907000000010' in 'where clause'")
打印下sql语句:
exe_sql==== select * from repay_plan WHERE loan_order_no=LO20220907000000011
我们发现【loan_order_no】的值是没有加引号的,把引号加上,就可以正常执行了
exe_sql = f"select * from repay_plan WHERE loan_order_no='{platformOrderNo}'" print('exe_sql====', exe_sql) db_res = self.client.mysql.exec_sql_query(exe_sql) print(db_res)
本文来自博客园,作者:他还在坚持嘛,转载请注明原文链接:他还在坚持嘛 https://www.cnblogs.com/brf-test/p/16665387.html