474,025 Members | 6,429 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to replace and string in a "SELECT ... IN ()"

Hi,

I have a BIIIIIG problem with the next query:

cursor.execute( """
SELECT titem.object_id , titem.tag_id
FROM tagging_taggedi tem titem
WHERE titem.object_id IN (%s)
""",( eid_list))

eid_list is suppossed to be a list of ids = [1,5,9]

How can I make it work?

Thanks
Sep 26 '08
11 2048
Michael Mabin wrote:
Tino, dude, I'm afraid I lied about my previous post being the last
word. There are some things you said here that must be addressed.
Good grief, is there no utterance so inconsequential that you will walk
away from it without yet another round of retaliation?

I believe that all people were trying to convey is:

1. There are some data patterns that cannot be directly incorporated
into SQL statements without additional processing, regardless of whether
the "intention" of the data's originator is malevolent. A good example
is a string value containing an apostrophe, which in most SQL
implementations you can escape by preceding the apostrophe with another
apostrophe.

2. SQL drivers in Python are written so that no matter what the values
of the data may be, and no matter which backend they implement, data may
safely be passed as a tuple to a parameterized statement without such
cleansing because the drivers are written to ensure "dangerous" values
are appropriately handled.

Having said all that, if you are positive none of your string data
contains apostrophes you are, of course, free to build SQL statements
yourself - though doing so will on some systems lose you the speed
advantages offered by "prepared statements". Similarly, if you are *not*
positive of the quality of your data you are free to do the escaping in
your logic rather than using parameterized queries. This could be called
"buying a dog and barking yourself".

regards
Steve
--
Steve Holden +1 571 484 6266 +1 800 494 3119
Holden Web LLC http://www.holdenweb.com/

Sep 28 '08 #11
In message <ma************ *************** ***********@pyt hon.org>, D'Arcy
J.M. Cain wrote:
On Fri, 26 Sep 2008 11:00:59 -0500
"Michael Mabin" <d3******@gmail .comwrote:
>So we can drop a table in an in clause? How is this a use case.
Cartoons are funny but actual proof that this example using an in-clause
provides an exploit would be more helpful I think.

I'm not sure what proof you require.
I would say Mr Mabin is displaying thinking characteristic of a PHP
programmer
<http://groups.google.c o.nz/group/nz.comp/msg/4c2a4d220499daf d>. :)

Sep 29 '08 #12

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

Similar topics

0
1364
by: Rick Brandt | last post by:
Here is a simplified example of what I am passing to a Java SAX parser within a servlet via an HTTPRequest... <?xml version="1.0"?> <Record> <ID>1092853685</ID> <Notes><!]></Notes> </Record> I get the following error in the server's log output...
6
56565
by: vigi98 | last post by:
Hello all, Can someone confirme that this: var strURLpiece = "UK & Ireland"; strURLpiece.replace("&", "%26"); replaces all occurrence of the character & by %26 in strURLpiece, ie that strURLpiece becomes "UK %26 Ireland" ? Thanks a lot.
3
10533
by: asd987 | last post by:
Hi, Can anyone tell me if "replace" is supported by Access 97? I use the Dutch version and get the errormessage "sub or function not supported". Or is the Professional Edition needed? Thanks.
2
4596
by: ad | last post by:
Hello, if I try this ((StringBuilder)sb).Replace("a", "aa"); I get OutOfMemoryException raised if sb contains at least one "a"... It seems like StringBuilder 'seeker' doesn't move to the end of replacement string but it moves to the second character of the replacement string...
6
29653
by: Marty | last post by:
Hi, I would like to replace "\r\n" by "_" within a specific string. I tried : strMyString.Replace('\r', '_'); strMyString.Replace('\n', '_'); or strMyString.Replace(System.Environment.NewLine, '_');
6
1389
by: Dean Slindee | last post by:
Private NameLastFirst as object = "Public, John Q." NameLastFirst = Replace(LastName, "'", "''") If NameLastFirst contains "Public, John Q." before the above Replace, it will contain "Public" after the Replace. At least that's how it's working in my version of VS.NET. That does not seem right to me. Am I missing something? Note that the replacement character(s) are *apostrophes*, not *commas*
2
3342
by: John Nagle | last post by:
I'm trying to clean up a bad ASCII string, one read from a web page that is supposedly in the ASCII character set but has some characters above 127. And I get this: File "D:\projects\sitetruth\InfoSitePage.py", line 285, in httpfetch sitetext = sitetext.encode('ascii','replace') # force to clean ASCII UnicodeDecodeError: 'ascii' codec can't decode byte 0x92 in position 29151: ordinal not in range(128)
5
1853
by: Curious | last post by:
I have: if (temp.Contains("Account") == true) { temp.Replace("Account", "Client"); } The "Account" is not replaced by "Client" after this operation. I used
3
1954
by: Curious | last post by:
I have another question about Regular Expression. If I use: if (temp.Contains("Ending") == true) { temp = System.Text.RegularExpressions.Regex.Replace(temp, "Ending", "Beginning"); } It seems that while "Ending" is replaced with "Beginning", it also
0
10487
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
10302
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
12057
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
11563
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
8638
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6601
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
6770
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
5349
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4901
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.