Zope Upload of Blobs into MySQL

2 messages Options
Embed this post
Permalink
skug84 () Zope Upload of Blobs into MySQL
Reply Threaded More More options
Print post
Permalink
Hi all!
I have a problem in uploading a file in a table mysql.
I have read this how-to http://www.zope.org/Members/murphy/MySQL-BLOBs but it doesn't work for me.
It gives me this error:
Time   2009/11/05 12:41:36.293 GMT+1
User Name (User Id) admin (admin)
Request URL http://localhost:8081/Plone/portal_skins/custom/Upload%20Photo/newPhoto.py
Exception Type ProgrammingError
Exception Value (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 '(Pic = '\xff\xd8\xff\xe0\\0\x10JFIF\\0\x01\x01\x01\\0H\\0H\\0\\0\xff\xdb\\0C\\0\x05\x03\x04\x04\x04\x03\x05\x04\x04\x04\x05\x05\x05\x06\x07\x0c\x08\x07\x07\x07\x07\x0f\x0b\x0b\t\x0c\x11\x0f\x12\x12\x11\x0f\x11\x11\x13\x16\x1c\x17\x13' at line 2")

Traceback (innermost last):

    * Module ZPublisher.Publish, line 119, in publish
    * Module ZPublisher.mapply, line 88, in mapply
    * Module ZPublisher.Publish, line 42, in call_object
    * Module Shared.DC.Scripts.Bindings, line 313, in __call__
    * Module Shared.DC.Scripts.Bindings, line 350, in _bindAndExec
    * Module Products.PythonScripts.PythonScript, line 328, in _exec
    * Module None, line 11, in newPhoto.py
      <PythonScript at /Plone/portal_skins/custom/Upload Photo/newPhoto.py>
      Line 11
    * Module Shared.DC.ZRDB.DA, line 500, in __call__
      <SQL at /Plone/portal_skins/custom/Upload Photo/insertPhoto>
    * Module Products.ZMySQLDA.db, line 284, in query

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 '(Pic = '\xff\xd8\xff\xe0\\0\x10JFIF\\0\x01\x01\x01\\0H\\0H\\0\\0\xff\xdb\\0C\\0\x05\x03\x04\x04\x04\x03\x05\x04\x04\x04\x05\x05\x05\x06\x07\x0c\x08\x07\x07\x07\x07\x0f\x0b\x0b\t\x0c\x11\x0f\x12\x12\x11\x0f\x11\x11\x13\x16\x1c\x17\x13' at line 2")

REQUEST
form
Photo <ZPublisher.HTTPRequest.FileUpload instance at 0x1040ea0c>
cookies
I18N_LANGUAGE 'it'
tree-s 'eJzTyCkw5NLIKTDiClZ3hANXW3WuAmOuxEQ9AIOOB9Q'
lazy items
SESSION <bound method SessionDataManager.getSessionData of <SessionDataManager at /session_data_manager>>
other
TraversalRequestNameStack []
LANGUAGE 'it'
AUTHENTICATED_USER <PropertiedUser 'admin'>
URL 'http://localhost:8081/Plone/portal_skins/custom/Upload%20Photo/newPhoto.py'
Photo <ZPublisher.HTTPRequest.FileUpload instance at 0x1040ea0c>
SERVER_URL 'http://localhost:8081'
LANGUAGE_TOOL <Products.PloneLanguageTool.LanguageTool.LanguageBinding instance at 0x1036bdcc>
AUTHENTICATION_PATH ''
traverse_subpath []
PUBLISHED <PythonScript at /Plone/portal_skins/custom/Upload Photo/newPhoto.py>
ACTUAL_URL 'http://localhost:8081/Plone/portal_skins/custom/Upload%20Photo/newPhoto.py'
URL0 http://localhost:8081/Plone/portal_skins/custom/Upload%20Photo/newPhoto.py
URL1 http://localhost:8081/Plone/portal_skins/custom/Upload%20Photo
URL2 http://localhost:8081/Plone/portal_skins/custom
URL3 http://localhost:8081/Plone/portal_skins
URL4 http://localhost:8081/Plone
URL5 http://localhost:8081
BASE0 http://localhost:8081
BASE1 http://localhost:8081
BASE2 http://localhost:8081/Plone
BASE3 http://localhost:8081/Plone/portal_skins
BASE4 http://localhost:8081/Plone/portal_skins/custom
BASE5 http://localhost:8081/Plone/portal_skins/custom/Upload%20Photo
BASE6 http://localhost:8081/Plone/portal_skins/custom/Upload%20Photo/newPhoto.py
environ
HTTP_COOKIE 'tree-s="eJzTyCkw5NLIKTDiClZ3hANXW3WuAmOuxEQ9AIOOB9Q"; I18N_LANGUAGE="it"'
SERVER_SOFTWARE 'Zope/(Zope 2.10.9-final, python 2.4.6, linux2) ZServer/1.1 Plone/3.3.1'
SCRIPT_NAME ''
REQUEST_METHOD 'POST'
HTTP_KEEP_ALIVE '300'
SERVER_PROTOCOL 'HTTP/1.1'
channel.creation_time 1257420885
CONNECTION_TYPE 'keep-alive'
HTTP_ACCEPT_CHARSET 'ISO-8859-1,utf-8;q=0.7,*;q=0.7'
HTTP_USER_AGENT 'Mozilla/5.0 (X11; U; Linux i686; it; rv:1.9.0.15) Gecko/2009102815 Ubuntu/9.04 (jaunty) Firefox/3.0.15'
HTTP_REFERER 'http://localhost:8081/Plone/portal_skins/custom/Upload%20Photo/uploadphoto'
SERVER_NAME '0.0.0.0'
REMOTE_ADDR '127.0.0.1'
PATH_TRANSLATED '/Plone/portal_skins/custom/Upload Photo/newPhoto.py'
SERVER_PORT '8081'
CONTENT_LENGTH '7341'
HTTP_HOST 'localhost:8081'
HTTP_ACCEPT 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'
GATEWAY_INTERFACE 'CGI/1.1'
HTTP_ACCEPT_LANGUAGE 'it-it,it;q=0.8,en-us;q=0.5,en;q=0.3'
CONTENT_TYPE 'multipart/form-data; boundary=---------------------------2656558898823713311415160676'
HTTP_ACCEPT_ENCODING 'gzip,deflate'
PATH_INFO '/Plone/portal_skins/custom/Upload Photo/newPhoto.py'

Can anyone help me?
Thanks
Sascha Gottfried () Re: Zope Upload of Blobs into MySQL
Reply Threaded More More options
Print post
Permalink
Hi,

obviouly you have an error in your SQL. You need to call the ZSQL method
with some optional parameters for useful debugging.

src__=1

When you pass a true value, the method returns the generated SQL source
(without executing it).


test__=1

When you pass a true value, the method returns the generated SQL source
and is executing the query  (returns a tuple (sql_source, result))


look at the code if you want:
http://svn.zope.de/zope.org/Zope/tags/2.12.0a4/src/Shared/DC/ZRDB/DA.py

print the generated SQL source to Plone Log (context.plone_log()) and have a look at the event.log in your zope instance.
This will show your SQL error. Dump this into your reply and AS WELL the the source of your ZSQL Method insertPhoto.

This is also very helpful for you:
http://docs.zope.org/zope2/zope2book/RelationalDatabases.html




skug84 schrieb:

> Hi all!
> I have a problem in uploading a file in a table mysql.
> I have read this how-to http://www.zope.org/Members/murphy/MySQL-BLOBs but
> it doesn't work for me.
> It gives me this error:
> Time   2009/11/05 12:41:36.293 GMT+1
> User Name (User Id) admin (admin)
> Request URL
> http://localhost:8081/Plone/portal_skins/custom/Upload%20Photo/newPhoto.py
> Exception Type ProgrammingError
> Exception Value (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 '(Pic =
> '\xff\xd8\xff\xe0\\0\x10JFIF\\0\x01\x01\x01\\0H\\0H\\0\\0\xff\xdb\\0C\\0\x05\x03\x04\x04\x04\x03\x05\x04\x04\x04\x05\x05\x05\x06\x07\x0c\x08\x07\x07\x07\x07\x0f\x0b\x0b\t\x0c\x11\x0f\x12\x12\x11\x0f\x11\x11\x13\x16\x1c\x17\x13'
> at line 2")
>
> Traceback (innermost last):
>
>     * Module ZPublisher.Publish, line 119, in publish
>     * Module ZPublisher.mapply, line 88, in mapply
>     * Module ZPublisher.Publish, line 42, in call_object
>     * Module Shared.DC.Scripts.Bindings, line 313, in __call__
>     * Module Shared.DC.Scripts.Bindings, line 350, in _bindAndExec
>     * Module Products.PythonScripts.PythonScript, line 328, in _exec
>     * Module None, line 11, in newPhoto.py
>       <PythonScript at /Plone/portal_skins/custom/Upload Photo/newPhoto.py>
>       Line 11
>     * Module Shared.DC.ZRDB.DA, line 500, in __call__
>       <SQL at /Plone/portal_skins/custom/Upload Photo/insertPhoto>
>     * Module Products.ZMySQLDA.db, line 284, in query
>
> 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 '(Pic =
> '\xff\xd8\xff\xe0\\0\x10JFIF\\0\x01\x01\x01\\0H\\0H\\0\\0\xff\xdb\\0C\\0\x05\x03\x04\x04\x04\x03\x05\x04\x04\x04\x05\x05\x05\x06\x07\x0c\x08\x07\x07\x07\x07\x0f\x0b\x0b\t\x0c\x11\x0f\x12\x12\x11\x0f\x11\x11\x13\x16\x1c\x17\x13'
> at line 2")
>
> REQUEST
> form
> Photo <ZPublisher.HTTPRequest.FileUpload instance at 0x1040ea0c>
> cookies
> I18N_LANGUAGE 'it'
> tree-s 'eJzTyCkw5NLIKTDiClZ3hANXW3WuAmOuxEQ9AIOOB9Q'
> lazy items
> SESSION <bound method SessionDataManager.getSessionData of
> <SessionDataManager at /session_data_manager>>
> other
> TraversalRequestNameStack []
> LANGUAGE 'it'
> AUTHENTICATED_USER <PropertiedUser 'admin'>
> URL
> 'http://localhost:8081/Plone/portal_skins/custom/Upload%20Photo/newPhoto.py'
> Photo <ZPublisher.HTTPRequest.FileUpload instance at 0x1040ea0c>
> SERVER_URL 'http://localhost:8081'
> LANGUAGE_TOOL <Products.PloneLanguageTool.LanguageTool.LanguageBinding
> instance at 0x1036bdcc>
> AUTHENTICATION_PATH ''
> traverse_subpath []
> PUBLISHED <PythonScript at /Plone/portal_skins/custom/Upload
> Photo/newPhoto.py>
> ACTUAL_URL
> 'http://localhost:8081/Plone/portal_skins/custom/Upload%20Photo/newPhoto.py'
> URL0
> http://localhost:8081/Plone/portal_skins/custom/Upload%20Photo/newPhoto.py
> URL1 http://localhost:8081/Plone/portal_skins/custom/Upload%20Photo
> URL2 http://localhost:8081/Plone/portal_skins/custom
> URL3 http://localhost:8081/Plone/portal_skins
> URL4 http://localhost:8081/Plone
> URL5 http://localhost:8081
> BASE0 http://localhost:8081
> BASE1 http://localhost:8081
> BASE2 http://localhost:8081/Plone
> BASE3 http://localhost:8081/Plone/portal_skins
> BASE4 http://localhost:8081/Plone/portal_skins/custom
> BASE5 http://localhost:8081/Plone/portal_skins/custom/Upload%20Photo
> BASE6
> http://localhost:8081/Plone/portal_skins/custom/Upload%20Photo/newPhoto.py
> environ
> HTTP_COOKIE 'tree-s="eJzTyCkw5NLIKTDiClZ3hANXW3WuAmOuxEQ9AIOOB9Q";
> I18N_LANGUAGE="it"'
> SERVER_SOFTWARE 'Zope/(Zope 2.10.9-final, python 2.4.6, linux2) ZServer/1.1
> Plone/3.3.1'
> SCRIPT_NAME ''
> REQUEST_METHOD 'POST'
> HTTP_KEEP_ALIVE '300'
> SERVER_PROTOCOL 'HTTP/1.1'
> channel.creation_time 1257420885
> CONNECTION_TYPE 'keep-alive'
> HTTP_ACCEPT_CHARSET 'ISO-8859-1,utf-8;q=0.7,*;q=0.7'
> HTTP_USER_AGENT 'Mozilla/5.0 (X11; U; Linux i686; it; rv:1.9.0.15)
> Gecko/2009102815 Ubuntu/9.04 (jaunty) Firefox/3.0.15'
> HTTP_REFERER
> 'http://localhost:8081/Plone/portal_skins/custom/Upload%20Photo/uploadphoto'
> SERVER_NAME '0.0.0.0'
> REMOTE_ADDR '127.0.0.1'
> PATH_TRANSLATED '/Plone/portal_skins/custom/Upload Photo/newPhoto.py'
> SERVER_PORT '8081'
> CONTENT_LENGTH '7341'
> HTTP_HOST 'localhost:8081'
> HTTP_ACCEPT
> 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'
> GATEWAY_INTERFACE 'CGI/1.1'
> HTTP_ACCEPT_LANGUAGE 'it-it,it;q=0.8,en-us;q=0.5,en;q=0.3'
> CONTENT_TYPE 'multipart/form-data;
> boundary=---------------------------2656558898823713311415160676'
> HTTP_ACCEPT_ENCODING 'gzip,deflate'
> PATH_INFO '/Plone/portal_skins/custom/Upload Photo/newPhoto.py'
>
> Can anyone help me? %-|
> Thanks
>  

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Plone-Users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/plone-users