error in inserting a longblob data

Discussion in 'Python' started by ketulp_baroda@yahoo.com, Feb 24, 2004.

  1. Guest

    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 say foo.txt it gets
    stored in database correctly whereas the file bar.txt gives an error.
    The error given is:


    Traceback (most recent call last):
    File "fakeloginserver.py", line 567, in _doRequest
    _handleRequest(_wfile)
    File "fakeloginserver.py", line 812, in _handleRequest
    response.body=_theMethod(**(request.paramMap))
    File "fakeloginserver.py", line 92, in invokeAddAttachment
    add.addAttachment(v,filename,values)
    File "C:\Python23\Lib\site-packages\cherrypy\code\Attachment_Model.py",
    line 26, in addAttachment
    n=cursor.execute("insert into attachments
    values('%s','%s','%s','%s','%s','%s','%s','%s','%s')"
    %(Attachment_Model.projectid[0],values['issueid'],attachID,datetime,values['attachmentdescription'],contenttype,filename,values['attachmentpath'],submitterID))
    File "C:\PYTHON23\Lib\site-packages\MySQLdb\cursors.py", line 95, in
    execute
    return self._execute(query, args)
    File "C:\PYTHON23\Lib\site-packages\MySQLdb\cursors.py", line 114,
    in _execute
    self.errorhandler(self, exc, value)
    File "C:\PYTHON23\Lib\site-packages\MySQLdb\connections.py", line
    33, in defaulterrorhandler
    raise errorclass, errorvalue
    ProgrammingError: (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.How can
    I make it work for all files??
    , Feb 24, 2004
    #1
    1. Advertising

  2. wes weston Guest

    ,

    Is it possible that the error is caused by a string
    that has an ' in it? Thus yielding something like
    'abc'xyz' - a string with an embedded '. The listed
    're looks suspecious; like it was the end of you're
    maybe.

    wes

    wrote:
    > 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 say foo.txt it gets
    > stored in database correctly whereas the file bar.txt gives an error.
    > The error given is:
    >
    >
    > Traceback (most recent call last):
    > File "fakeloginserver.py", line 567, in _doRequest
    > _handleRequest(_wfile)
    > File "fakeloginserver.py", line 812, in _handleRequest
    > response.body=_theMethod(**(request.paramMap))
    > File "fakeloginserver.py", line 92, in invokeAddAttachment
    > add.addAttachment(v,filename,values)
    > File "C:\Python23\Lib\site-packages\cherrypy\code\Attachment_Model.py",
    > line 26, in addAttachment
    > n=cursor.execute("insert into attachments
    > values('%s','%s','%s','%s','%s','%s','%s','%s','%s')"
    > %(Attachment_Model.projectid[0],values['issueid'],attachID,datetime,values['attachmentdescription'],contenttype,filename,values['attachmentpath'],submitterID))
    > File "C:\PYTHON23\Lib\site-packages\MySQLdb\cursors.py", line 95, in
    > execute
    > return self._execute(query, args)
    > File "C:\PYTHON23\Lib\site-packages\MySQLdb\cursors.py", line 114,
    > in _execute
    > self.errorhandler(self, exc, value)
    > File "C:\PYTHON23\Lib\site-packages\MySQLdb\connections.py", line
    > 33, in defaulterrorhandler
    > raise errorclass, errorvalue
    > ProgrammingError: (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.How can
    > I make it work for all files??
    wes weston, Feb 24, 2004
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    63
    Views:
    14,697
    christhevet
    Mar 20, 2011
  2. Bhavesh
    Replies:
    0
    Views:
    422
    Bhavesh
    Jul 16, 2007
  3. Bhavesh
    Replies:
    5
    Views:
    626
    Bhavesh
    Jul 18, 2007
  4. Bhavesh
    Replies:
    1
    Views:
    450
    Bhavesh
    Jul 17, 2007
  5. Renie83
    Replies:
    1
    Views:
    175
    Kiran Math
    Jul 10, 2003
Loading...

Share This Page