Python中字符串到SQL的列表

2024-09-30 07:35:00 发布

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

我在python中有一个查询:

ssim_group = [S1200,S1300]

query = '''select WIPMessageCnt from waferdata where recipename in (%s) and equipment = ?
                             and runtype = ? order by  stopts desc limit 1''' % (','.join(ssim_grp))

打印查询

当前结果

select WIPMessageCnt from waferdata where recipename in (S1200,S1460) and equipment = ? and runtype = ? order by stopts desc limit 1

预期结果应该是这样的

select WIPMessageCnt from waferdata where recipename in ('S1200','S1460') and equipment = ? and runtype = ? order by stopts desc limit 1

当我尝试将它们放入SQL的IN参数中时,该列表中的每个元素都应该有一个quation。我怎样才能做到这一点?在


Tags: andinfrombyorderwhereselectdesc
1条回答
网友
1楼 · 发布于 2024-09-30 07:35:00
ssim_group = ['S1200', 'S1300']
query = '''select WIPMessageCnt from waferdata where recipename in ('%s') and equipment = ? and runtype = ? order by  stopts desc limit 1''' % ("','".join(ssim_group))

相关问题 更多 >

    热门问题