Hi, i’m trying to read images from a existing sqlite db. For some reason when i 
save the images to disk, they are corrupted.
this is my code:

cherry_db = DAL('sqlite://{}'.format(form.vars.cherry_file), 
folder=upload_folder, migrate=False)

cherry_db.define_table('image',
Field('node_id', 'integer', requires=IS_NOT_EMPTY()),
Field('png', 'blob')
)

images = cherry_db(cherry_db.image.node_id == 
i['node_id']).select(cherry_db.image.node_id, cherry_db.image.png)

for m in images:
name = str(uuid.uuid4())
print('image {}'.format(name))
print(m['png'])
im = open('{}'.format(session.project_folder+'/'+name+'.png'), 'wb')
im.write(m['png'])
im.close()

Any help is appreciated

Cheers.
Chris.

--
Sent from Canary (https://canarymail.io)

-- 
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].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/30b99d7b-941c-4387-80cd-9f521399af82%40Canary.

Reply via email to