Problem with format string / MySQL cursor

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Fri Oct 19 17:50:20 EDT 2007


En Fri, 19 Oct 2007 05:32:04 -0300, Dennis Lee Bieber  
<wlfraed at ix.netcom.com> escribió:

> On Thu, 18 Oct 2007 13:40:53 -0700, Florian Lindner
> <Florian.Lindner at xgm.de> declaimed the following in comp.lang.python:

>> That works! Thanks! But a weird error message for this solution...
>
> 	Not really... The MySQLdb adapter converts all parameters to
> properly delimited STRINGS (I don't know of any SQL system that passes
> /binary/ numerics). But MySQLdb also uses Python % formatting to then

I'd say the opposite: only poorly implemented systems convert numeric  
arguments to text.
*Real* bound variables are passed as pointers. The SQL sentence can be  
prepared and re-used with different sets of values several times, without  
having to re-parse it again and again.
If the MySQLdb adapter actually converts and inserts the arguments itself  
into the supplied SQL sentence, generating a new string for each call,  
this advantage -and many others- are cancelled, defeating the purpose of  
bound variables.

-- 
Gabriel Genellina




More information about the Python-list mailing list