[Zope] Getting BLOB data from a MySQL DB.
    Terry Hancock 
    hancock at anansispaceworks.com
       
    Mon May 10 20:44:56 EDT 2004
    
    
  
On Monday 10 May 2004 06:25 pm, Jason C. Leach wrote:
> Hi, is it possible to get BLOB data from a MySQL DB and send it as a 
> file to a user?  I would like to store several PDFs this way.  Linking 
> to them on the HDD is not really an option.
Sure, just direct the user to a python script that calls ZSQL to get
the data and returns the unadorned BLOB data (i.e. as a string).
e.g. the python script looks something like this (takes one argument "recid" in
this example, which is supposed to identify the correct record in MySQL):
pdf_recordlist = context.get_pdf_file_record(recid='foo')  # call a ZSQL method to get the record
if len(pdf_recordlist) > 0:
    pdf_data = pdf_recordlist[0].fulltext          # the BLOB is the "fulltext" field
else:
    pdf_data = ''
return pdf_data
That sort of thing.
HTH,
Terry
--
Terry Hancock ( hancock at anansispaceworks.com )
Anansi Spaceworks  http://www.anansispaceworks.com
    
    
More information about the Zope
mailing list