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

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

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 之后有尾随逗号



欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/5675151.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-16
下一篇 2022-12-17

发表评论

登录后才能评论

评论列表(0条)

保存