gpt4 book ai didi

python - 如何在mysql查询中传递字典对象值作为参数?

转载 作者:行者123 更新时间:2023-11-29 21:09:45 26 4
gpt4 key购买 nike

我正在获取客户列表[{'id': 31L}, {'id': 35L}],并在选择查询中如何将 id 作为参数传递?

查询

for customer in customer_list:
"select * from base_order where location_id=%s and city='Hyderabad'", (customer['id'])

但它给出错误TypeError:无法连接'str'和'tuple'对象

最佳答案

您是否尝试过在 id 两边加上引号以使每个 id 成为字符串? IE。 '31L'

关于python - 如何在mysql查询中传递字典对象值作为参数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36485098/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com