473,398 Members | 2,393 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

python & mysql probelm

Hi
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??
Regards,
James
Jul 18 '05 #1
1 1280
james blair wrote:
Hi
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??
Regards,
James


James,
As strings 11 is less than 2. Are your fields strings
or ints? If you change them from strings to ints, mysql
will make the translation.
wes

Jul 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Peter Moscatt | last post by:
Will Python work with any of the databases like MySQL... ? Pete
3
by: james blair | last post by:
Hi I have a search page & the reults for the search are fetched from the database. I want that on the results page only first 25 results are shown & a link "next 25 results" be shown.Same for the...
7
by: Matthias Verniers | last post by:
Hello Yesterday I installed Python 2.4. Since I often work with MySQL, I need the MySQLdb module, wich worked fine under 2.3. Now, it doesn't work under 2.4, it says it needs python 2.3 when I...
1
by: Smita | last post by:
hello ! > > > I am trying to intstall Mysql binary version with installor in Windows > XP machine . But it is not working . i have installed in the default > path ,in windows service componenet...
4
by: MLH | last post by:
A programmer developed an AMP (Apache/MySQL/PHP) application for me. When he was done, he sent me the PHP files and the MySQL dump file. Now, when I connect to the application on my LAN using...
13
by: Steven Bethard | last post by:
Jean-Paul Calderone <exarkun@divmod.comwrote: Interesting. Could you give a few illustrations of this? (I didn't run into the same problem at all, so I'm curious.) Steve
1
by: Steve Ametjan | last post by:
I've been trying to get MySQL-python to install on Leopard for the past couple of days, and I keep running into relatively the same error. I'm hoping that someone on this list will be able to...
0
by: OldManRiver | last post by:
All, I downloaded the OpenEMM (Linux & Windows) to install. The Windows version uses Python as the Installer and the programmer for this installer made some bad assumptions about the...
0
by: Scotsman | last post by:
Hi All I have a sticky problem! Its a LEFT JOIN sql statement which works fine in MySQL but not when called in Perl. Any ideas? I have 2 tables: campaigns & companies. I'm trying to join them...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.