3

I have this query in 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))

print query

Current result

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

Expected result should be like this

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

The list should have single qoutation on each element when I try to put them inside the IN parameter on SQL. How can I achieve this?

ellaRT
  • 1,346
  • 2
  • 16
  • 39

1 Answers1

5
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))
yanghaogn
  • 833
  • 7
  • 15