How to correctly submit list as an argument to MySQLdb

15.02.2011

We have something like this as query:

query = """SELECT *
           FROM users
           WHERE id IN %s
           """ 

And we have a list with users ids (something as [1,2,3]).
We need to pass this list in a execute statement as:

cursor. execute (query, (argument, ))

The right way to do it is to make sure that argument is a list with INTEGERS as elements.

 
python/mysqldbseq.txt · Last modified: 2011/11/25 10:45 (external edit)
Email address
 
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki