我得到0个结果,但记录在数据库中

2024-03-29 01:39:01 发布

您现在位置:Python中文网/ 问答频道 /正文

我的python代码在XML文件上运行,并检查所有引用是否都在数据库(MySQL数据库)中。 当产品不在数据库中时,输出为“产品不在数据库中” 检查过程在python代码中:

                str_sql = "select id_product from ps_product where reference = '" + makat + "';"
                str_sql = str_sql.replace('"\"', "")
                productID = get_productId(str_sql)
                if (productID == 'error' or productID == 'None'):
                    errorReason = "product don't exsits in DB"
                    print("error: product don't exsits in DB -  ", productName,", ",makat)

例如,所需的参考是F0FB0056IV。 该引用在DB table ps_product中有一条记录,但仍然得到0个结果

为什么?