Gadfly use (Newby)

N

niko

Hello,
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.
 
F

Fredrik Lundh

niko said:
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>
 
S

Steve Holden

Fredrik said:
the "%" operator does the substitution *before* the execute method is
called.

maybe you meant




?

</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
 
D

Dennis Lee Bieber

Off hand...

I'd suspect a problem with that * and the mass of quotes.
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, ))

Well... I don't know the Gadfly code, but the MySQLdb code is
perfectly happy with a non-tuple for single substitution... But yes, in
either case I believe what /should/ be used is the deferred parameter
substitution using the db-api defined form; properly implemented, it
should escape that * and embedded 's...
--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top