error in inserting a long blob data

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • ketulp_baroda@yahoo.com

    error in inserting a long blob data

    Hi
    I am storing the attachment in the database. For some file the data
    gets stored in the database but for other files it gives a MySql
    error. For eg. when I am trying to attach the file foo.txtit gets
    stored in database correctly whereas the file bar.txt gives an error.
    The error given is:


    Traceback (most recent call last):
    File "fakeloginserve r.py", line 567, in _doRequest
    _handleRequest( _wfile)
    File "fakeloginserve r.py", line 812, in _handleRequest
    response.body=_ theMethod(**(re quest.paramMap) )
    File "fakeloginserve r.py", line 92, in invokeAddAttach ment
    add.addAttachme nt(v,filename,v alues)
    File "C:\Python23\Li b\site-packages\cherry py\code\Attachm ent_Model.py",
    line 26, in addAttachment
    n=cursor.execut e("insert into attachments
    values('%s','%s ','%s','%s','%s ','%s','%s','%s ','%s')"
    %(Attachment_Mo del.projectid[0],values['issueid'],attachID,datet ime,values['attachmentdesc ription'],contenttype,fi lename,values['attachmentpath '],submitterID))
    File "C:\PYTHON23\Li b\site-packages\MySQLd b\cursors.py", line 95, in
    execute
    return self._execute(q uery, args)
    File "C:\PYTHON23\Li b\site-packages\MySQLd b\cursors.py", line 114,
    in _execute
    self.errorhandl er(self, exc, value)
    File "C:\PYTHON23\Li b\site-packages\MySQLd b\connections.p y", line
    33, in defaulterrorhan dler
    raise errorclass, errorvalue
    ProgrammingErro r: (1064, "You have an error in your SQL syntax. Check
    the manual that corresponds to your MySQL server version for the right
    syntax to use near 're just getting started with CherryPy, read the
    tutorial (in do")


    values['attachmentpath '] contains the file data.
    The data type of the file data is LONGBLOB in MySql.
    I am not getting why it works for some file but not for others.
  • Diez B. Roggisch

    #2
    Re: error in inserting a long blob data

    >[color=blue]
    > values['attachmentpath '] contains the file data.
    > The data type of the file data is LONGBLOB in MySql.
    > I am not getting why it works for some file but not for others.[/color]

    Do you have single quotes in your attachment - these would confuse the mysql
    parser. I don't remember how to quote them for mysql (in oracle its '' for
    a single quote) - but thats in the manuals.

    --
    Regards,

    Diez B. Roggisch

    Comment

    • ketulp_baroda@yahoo.com

      #3
      Re: error in inserting a long blob data

      "Diez B. Roggisch" <deets_noospaam @web.de> wrote in message news:<c1ht2m$u7 c$01$2@news.t-online.com>...[color=blue][color=green]
      > >
      > > values['attachmentpath '] contains the file data.
      > > The data type of the file data is LONGBLOB in MySql.
      > > I am not getting why it works for some file but not for others.[/color]
      >
      > Do you have single quotes in your attachment - these would confuse the mysql
      > parser. I don't remember how to quote them for mysql (in oracle its '' for
      > a single quote) - but thats in the manuals.[/color]

      How to escape such sequences in python

      Comment

      • wes weston

        #4
        Re: error in inserting a long blob data

        Diez,
        From your error, you have a DB driver problem. MySql
        says to use something like 'they''re' - double up the
        inner '


        ketulp_baroda@y ahoo.com wrote:[color=blue]
        > "Diez B. Roggisch" <deets_noospaam @web.de> wrote in message news:<c1ht2m$u7 c$01$2@news.t-online.com>...
        >[color=green][color=darkred]
        >>>values['attachmentpath '] contains the file data.
        >>>The data type of the file data is LONGBLOB in MySql.
        >>>I am not getting why it works for some file but not for others.[/color]
        >>
        >>Do you have single quotes in your attachment - these would confuse the mysql
        >>parser. I don't remember how to quote them for mysql (in oracle its '' for
        >>a single quote) - but thats in the manuals.[/color]
        >
        >
        > How to escape such sequences in python[/color]

        Comment

        Working...