python & mysql probelm

Batista, Facundo FBatista at uniFON.com.ar
Fri Mar 26 22:20:52 CET 2004


talktojamesblair wrote:

#- I am having a problem executing following query:
#- cursor.execute("select * from projects where projectid between '%s'
#- and '%s'"%(id1,id2))
#- But say if i have projectid's from 1 to 20 in database & if 
#- i give the
#- project range 1 to 2 then it gives me the result 1,2,11,12,13,14.....
#- When I execute this query in mysql i.e
#- select * from projects where projectid between 1 and 2,I get the
#- correct result.
#- I also tried doing 
#- cursor.execute("select * from projects where projectid between '%s'
#- and '%s'"%(int(id1),int(id2))
#- but no success
#- What should I do??

Try to execute *this* query in mysql:

select * from projects where projectid between '1' and '2';

*That* is what you really are executing through cursor.execute(...)

A very useful method I use to debug this kind of stuff is to print the
statement. Then I copy&paste that in mysql.

.	Facundo




More information about the Python-list mailing list