User Tools

Site Tools


python:mysqldbseq

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

python:mysqldbseq [2013/03/16 17:40] (current)
Line 1: Line 1:
 +==== How to correctly submit list as an argument to MySQLdb ====
 +15.02.2011
  
 +
 +We have something like this as query:
 +
 +<​code>​
 +query = """​SELECT *
 +           FROM users
 +           WHERE id IN %s
 +           """ ​
 +</​code>​
 +
 +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: 2013/03/16 17:40 (external edit)