栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

SQL Python,处理 Where 语句中的一个或多个值

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

SQL Python,处理 Where 语句中的一个或多个值

实施该更改后,我没有收到 Numpy 错误,而是格式错误。所以做了下面的改动

filename = 'test.csv'division = test.iloc[0][4]division_tuple = tuple(map(int, str(division).split(",")))sql = cs.execute("""INSERT INTO sample_table_nameselect c.customer_id,c.customer_namefrom(t.customer_idt.customer_namefrom customer_table twhere division_id in (%s) --changed format here group by 1,2) c ;""",(division_tuple)) #and here 

虽然这在技术上会使 where 子句在只有一个值时看起来像

“where Division_id in (92,)”
,但这仍然是运行它的正确方法,尽管在 92 之后有尾随逗号。



转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/669902.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号