[mod_python] "TypeError: argument 2 must be a mapping" and other things

Jorey Bump list at joreybump.com
Tue Sep 20 19:11:25 EDT 2005


Daniel Winkler wrote:
> Hello Jorey,
> 
> Am Dienstag, den 20.09.2005, 17:58 -0400 schrieb Jorey Bump:
> 
> 
>>You're mixing python string replacement with placeholders. You need to 
>>escape the placeholders (and the semicolon isn't necessary here):
>>
>>acl.execute("SELECT * FROM acl WHERE c = %%s AND d = %%s", (cID, dID))
> 
> 
> What kind of "placeholders" do you mean? Just to be sure: I did not want
> to use SQL placeholders. Okay, I tried your version, but unfortunately
> the error was the same ...
> 
> Thanks for your quick answer. Any other ideas? :-)

Note to self: test answers before dispensing bad advice. I'm the 
confused one here, it's only necessary to escape placeholders when 
*contructing* queries with python string replacement, i.e.:

table = "acl"
query = "SELECT * FROM %s WHERE c = %%s AND d = %%s" % (table)
acl = db.cursor()
acl.execute(query, (cID, dID))

So, the structure of your original query is fine, uses SQL placeholders 
(a good thing), and you indicate that it works in the interactive 
interpreter. Can you provide a little more of the code?







More information about the Mod_python mailing list