def use_name_get_goods_id(self, goods_name):
"""
用商品名称(列表)查找商品ID
:return:
"""
# Read a single record, if change database you need connection.commit()
sql = "SELECT `id`,`name`,`ip_name`,`sales_price` FROM `tide_boxes_goods` WHERE `name` in (%s)" % ','.join(
['%s'] * len(goods_name))
self.cursor.execute(sql, goods_name)
result = self.cursor.fetchall()
print(result)
# print(result.get("id"))
return result
['猫咪开餐', '早安']
[{'id': 90, 'name': '早安', 'ip_name': 'Molly', 'sales_price': Decimal('57.00')}, {'id': 94, 'name': '猫咪开餐', 'ip_name': 'Molly', 'sales_price': Decimal('39.00')}]
思路:按位置数量生成 %s,直接传列表进来
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有