Rather than just having a "blob" field, you might instead want an "upload" 
field along with an associated "blob" field. The .store() and .retrieve() 
methods (which are documented here 
<http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#More-on-uploads>),
 
operate on "upload" fields, not "blob" fields. Upload fields store the 
encoded *names *of uploaded files, whereas blob fields (if used in 
conjunction with an upload field) store the actual file contents. If you 
use an upload field, it will manage the encoded naming and retrieval (as 
well as the storage itself if using a SQLFORM).

Also, you didn't show how you did the insert, but the code you did show 
doesn't quite make sense, as the .to_csv() method shown gets passed an 
object called _tmp_data, which is not the StringIO object created in the 
previous line.

Anthony

On Wednesday, May 3, 2017 at 3:02:12 PM UTC-4, Scorpa wrote:
>
> Hello folks ! 
>
> I have database that's have BLOB type to store any kind of data (it's 
> should be binary ?):
>
> Field('f_blob', type='blob',
>       label=T('blob object')),
>
>
> I'm inserting new records with:
>
> db.t_cache.insert(f_name='processed_' + request.vars.filename, f_blob= data)
>
>
> Where data is pandas object which is covnerted to CSV:
>
> data = StringIO.StringIO()
> source.to_csv(_tmp_data)
> data.seek(0)
>
>
> In database DATA record appears. but i can't fnd any information about 
> retrieving this object from db.
>
>
> I tried RETRIEVE method (where the hell documenation about this ? no comments 
> in source)
>
> Such as:
>
> db.t_cache.f_blob.retrieve(db.t_cache[ID].f_blob).f_blob  gives = 
> {TypeError}Can't retrieve <StringIO.StringIO instance at 0x03BD95A8> file 
> properties
>
>
> db.t_cache.f_blob.retrieve(db.t_cache[ID]) = {TypeError}expected string or 
> buffer
>
>
> So how to get back BLOB object from databse and use it later ? 
>
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to