error in inserting a long blob data

K

ketulp_baroda

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 "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.
 
D

Diez B. Roggisch

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.

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.
 
K

ketulp_baroda

Diez B. Roggisch said:
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.

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.

How to escape such sequences in python
 
W

wes weston

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


Diez B. Roggisch said:
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.

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.


How to escape such sequences in python
 

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
474,008
Messages
2,570,269
Members
46,870
Latest member
hemasindhura

Latest Threads

Top