MySQLdb select

Sibylle Koczian Sibylle.Koczian at Bibliothek.Uni-Augsburg.de
Wed Aug 4 11:03:49 CEST 2004


Dennis Lee Bieber schrieb:
> On Tue, 03 Aug 2004 15:02:21 +0200, Sibylle Koczian
> <Sibylle.Koczian at Bibliothek.Uni-Augsburg.de> declaimed the following in
> comp.lang.python:
> 
> 
> 
>>I'm quite surprised that it works the other way - but it does. Could it 
>>be that previous versions of MySQLdb raised an exception with the other form
>>
> 
>  
> 	Well, from the MySQLdb code itself, we have these little
> comments...
> 
> -=-=-=-=-=-=-
>     def literal(self, o):
>         """
> 
>         If o is a single object, returns an SQL literal as a string.
>         If o is a non-string sequence, the items of the sequence are
>         converted and returned as a sequence.
> 
>         Non-standard.
> 
>         """

I don't see where "literal" comes into this?

> -=-=-=-=-=-=-
>     def execute(self, query, args=None):
> 
>         """Execute a query.
>         
>         query -- string, query to execute on server
>         args -- optional sequence or mapping, parameters to use with
> query.
> 
>         Note: If args is a sequence, then %s must be used as the
>         parameter placeholder in the query. If a mapping is used,
>         %(key)s must be used as the placeholder.
> 
>         Returns long integer rows affected, if any
> 
>         """

That would confirm that a single string or number is not a correct args 
parameter, wouldn't it? There is nothing here like "if args is no 
sequence, it is treated as a tuple of length one" - but this seems to be 
what happens.

Koczian



More information about the Python-list mailing list