473,761 Members | 2,455 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1301
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
1313
by: Peter Moscatt | last post by:
Will Python work with any of the databases like MySQL... ? Pete
3
1511
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 2nd result page. How do I do this?
7
4147
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 try to install the module. Now I have some (rather nooby) questions: 1. Has anyone tried installing MySQLdb 1.0 under Python 2.4 and has he succeeded? Please let me know how to do it or where I can find more information. 2. Is it possible to use...
1
1601
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 its showing server is running,since > it is mysqld-nt so name-piped servr is also running. > > But still client is able to connect to server. >
4
2812
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 http://192.168.1.106/~mlh/credifree/index.php the AMP app still thinks the data resides somewhere else. It runs fine - as long as I leave my LAN's external internet connection up. But if I unplug my LAN from the world, my app locks up. Before I...
13
2160
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
3015
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 help me out in solving the issue. I'd like to get this solved so I can continue developing with Django using MySQL since that's what my web server uses as well. I'd hate to have to develop using a different database engine on my local...
0
1165
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 installations. I posted a run-down of the install problems at: http://www.openemm.org/forums/viewtopic.php?p=2101#2101
0
1755
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 so that all columns of both tables are returned when 2 fields match across the tables and some additional tests in the first table. It works fine in MySQL but returns an empty set when called in Perl. Is there some limitation in Perl or a better way...
0
9538
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9353
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10123
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9975
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9909
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9788
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6623
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
3
3481
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2765
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.