Gadfly use (Newby)

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • niko

    #1

    Gadfly use (Newby)

    Hello,
    while using gadfly, got an error that i don't understand.
    Code is as follow :
    cursor = connection.curs or()
    cursor.execute( 'select id_m from mots where nom_m = "%s"' % nom_m)
    id_m = cursor.fetchall ()

    Error message :
    File "C:\Python24\Li b\site-packages\gadfly \kjParser.py", line 567, in
    getmember
    (Token,skip) = self.LexDict.To ken(self.String , self.Position)
    File "C:\Python24\Li b\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.

  • Fredrik Lundh

    #2
    Re: Gadfly use (Newby)

    "niko" <n.couturier@no os.fr> wrote:[color=blue]
    > while using gadfly, got an error that i don't understand.
    > Code is as follow :
    > cursor = connection.curs or()
    > cursor.execute( 'select id_m from mots where nom_m = "%s"' % nom_m)
    > id_m = cursor.fetchall ()
    >
    > Error message :
    > File "C:\Python24\Li b\site-packages\gadfly \kjParser.py", line 567, in
    > getmember
    > (Token,skip) = self.LexDict.To ken(self.String , self.Position)
    > File "C:\Python24\Li b\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.[/color]

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

    maybe you meant
    [color=blue]
    > cursor.execute( 'select id_m from mots where nom_m = %s', nom_m)[/color]

    ?

    </F>



    Comment

    • Steve Holden

      #3
      Re: Gadfly use (Newby)

      Fredrik Lundh wrote:[color=blue]
      > "niko" <n.couturier@no os.fr> wrote:
      >[color=green]
      >>while using gadfly, got an error that i don't understand.
      >>Code is as follow :
      >> cursor = connection.curs or()
      >> cursor.execute( 'select id_m from mots where nom_m = "%s"' % nom_m)
      >> id_m = cursor.fetchall ()
      >>
      >>Error message :
      >>File "C:\Python24\Li b\site-packages\gadfly \kjParser.py", line 567, in
      >>getmember
      >> (Token,skip) = self.LexDict.To ken(self.String , self.Position)
      >> File "C:\Python24\Li b\site-packages\gadfly \kjParser.py", line 433, in
      >>Token
      >> raise LexTokenError, "Lexical token not found "+info
      >>gadfly.kjPars er.LexTokenErro r: 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.[/color]
      >
      >
      > the "%" operator does the substitution *before* the execute method is
      > called.
      >
      > maybe you meant
      >
      >[color=green]
      >> cursor.execute( 'select id_m from mots where nom_m = %s', nom_m)[/color]
      >
      >
      > ?
      >
      > </F>
      >
      >
      >[/color]
      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/

      Comment

      • Dennis Lee Bieber

        #4
        Re: Gadfly use (Newby)

        On Wed, 17 Aug 2005 11:01:42 +0100, Steve Holden <steve@holdenwe b.com>
        declaimed the following in comp.lang.pytho n:
        [color=blue]
        > Fredrik Lundh wrote:[color=green]
        > > "niko" <n.couturier@no os.fr> wrote:
        > >[color=darkred]
        > >>while using gadfly, got an error that i don't understand.
        > >>Code is as follow :
        > >> cursor = connection.curs or()
        > >> cursor.execute( 'select id_m from mots where nom_m = "%s"' % nom_m)
        > >> id_m = cursor.fetchall ()
        > >>
        > >> raise LexTokenError, "Lexical token not found "+info
        > >>gadfly.kjPars er.LexTokenErro r: Lexical token not found near ::
        > >>' where nom_m = '*'"Ancient s Pled'
        > >>[/color][/color][/color]
        Off hand...

        I'd suspect a problem with that * and the mass of quotes.
        [color=blue][color=green]
        > >[color=darkred]
        > >> cursor.execute( 'select id_m from mots where nom_m = %s', nom_m)[/color]
        > >
        > >[/color][/color]
        [color=blue]
        > 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, ))
        >[/color]

        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...
        --[color=blue]
        > =============== =============== =============== =============== == <
        > wlfraed@ix.netc om.com | Wulfraed Dennis Lee Bieber KD6MOG <
        > wulfraed@dm.net | Bestiaria Support Staff <
        > =============== =============== =============== =============== == <
        > Home Page: <http://www.dm.net/~wulfraed/> <
        > Overflow Page: <http://wlfraed.home.ne tcom.com/> <[/color]

        Comment

        Working...