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?

2

1 Answer 1

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))
Sign up to request clarification or add additional context in comments.

1 Comment

this does not work if string has a quote like ['S1200', "S1300's"]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.