Reputation: 110163
I am trying to do the following query:
people = ('mike', 'dave', 'andrew')
cursor.execute('SELECT * FROM peoples WHERE person IN %s', people)
However, this raises a SQL exception. What would be the correct formatting for using an IN *python tuple()*
in mysql?
Upvotes: 1
Views: 80
Reputation: 31895
sql_stmt = 'SELECT * FROM peoples WHERE person IN (%s)' % ','.join(map(str,people))
cursor.execute(sql_stmt)
Upvotes: 3