python - Save BLOB into MySQL using web2py -


Using the Web2py Framework I want to select a file through a file type input and save it to a MySQL BLOB type field. The file contains binary data.

I need to use DAL for connection management, but I have a SQL process to work with me. The problem is that when I try it down I get error for SQL syntax Meets.

  f = form.vars.element.file.read () db.executesql ("some process (" F + "');")  

I have tried to insert raw binary in several ways and get the same or similar error. I have also tried to use MySQLdb directly:

  f = form.vars.element.file Read () db.cursor (). Execute ("call some process ('" + f + "');") Db.commit ()  

This works perfectly but I have to use the above DAL version Is required so that the problem is still open.

I have spent 3 days without this destiny. :( Please help!

I'm not sure why your second example works That the DAL.executesql method eventually calls the cursor (.) Execute exactly the same way () in any case, if you combine with web2py DAL object, you can access the cursor through db._adaptor.cursor . So, your second The example will change in:

  db = DAL ('Mysql: // ...') db._adapter.cursor.execute ("some process ('+ + +' + ''); ")  

Another option to use may be .callproc method:

  db._adapter.cursor Note:   

Code> db.executesql ('... WHERE name =% s', ('Marie',))

But I'm not sure that to run the logic in a stored procedure Will work.


Comments

Popular posts from this blog

winforms - C# Form - Property Change -

c# - NewtonSoft JArray - how to select multiple elements with LINQ -

javascript - amcharts makechart not working -