0

Basically I need to input a list in a query. It works very well with strings only but nut lists.

cursor.execute('select * from nicknames where name = %;', ('Smith', ))

So this one works, but then when I want to do the same with two names, then nothing.

cursor.execute('select * from nicknames where name in %s', ('(Smith, Andy)', ))

Do you know how I can make such a query ? Thanks

0

1 Answer 1

1

You can format it with the brackets inside the query like so:

cursor.execute('select * from nicknames where name in (%s, %s)', ("Smith", "Andy"))
Sign up to request clarification or add additional context in comments.

Comments

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.