SQL IN statement

45 views
Skip to first unread message

Peter Bočan

unread,
Aug 21, 2017, 4:45:31 AM8/21/17
to PyMySQL Users
Hello guys,

I want to execute this statement "SELECT something FROM table WHERE field IN (1,2,3...)" the question is, how to build such a query in PyMySQL where I want use "IN" statement. 

best wishes, 
Peter Bocan.

INADA Naoki

unread,
Aug 21, 2017, 5:28:10 AM8/21/17
to pymysq...@googlegroups.com
1. Use ORMs
2. cur.execute(f"SELECT ... IN ({','.join('?' for _ in range(len(ids)))})", ids)
INADA Naoki <songof...@gmail.com>
> --
> You received this message because you are subscribed to the Google Groups
> "PyMySQL Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to pymysql-user...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages