Gadfly use (Newby)

Steve Holden steve at holdenweb.com
Wed Aug 17 12:01:42 CEST 2005


Fredrik Lundh wrote:
> "niko" <n.couturier at noos.fr> wrote:
> 
>>while using gadfly, got an error that i don't understand.
>>Code is as follow :
>> cursor = connection.cursor()
>> cursor.execute('select id_m from mots where nom_m = "%s"' % nom_m)
>> id_m = cursor.fetchall()
>>
>>Error message :
>>File "C:\Python24\Lib\site-packages\gadfly\kjParser.py", line 567, in
>>getmember
>>   (Token,skip) = self.LexDict.Token(self.String, self.Position)
>> File "C:\Python24\Lib\site-packages\gadfly\kjParser.py", line 433, in
>>Token
>>   raise LexTokenError, "Lexical token not found "+info
>>gadfly.kjParser.LexTokenError: Lexical token not found near ::
>>' where nom_m = '*'"Ancient s Pled'
>>
>>Stored value seems to interfere with somethong ? Am i wrong ? Did i
>>missed something ? Thanks in advance for any help.
> 
> 
> the "%" operator does the substitution *before* the execute method is
> called.
> 
> maybe you meant
> 
> 
>> cursor.execute('select id_m from mots where nom_m = %s', nom_m)
> 
> 
> ?
> 
> </F> 
> 
> 
> 
I suspect he actually meant

   cursor.execute("select id_m from mots where nom_m = '%s'" % nom_m)

or perhaps

   cursor.execute("select id_m from mots where nom_m = %s", (nom_m, ))

regards
  Steve
-- 
Steve Holden       +44 150 684 7255  +1 800 494 3119
Holden Web LLC             http://www.holdenweb.com/




More information about the Python-list mailing list