I think you have to convert the image file to binary data before saving tad blob etc..?
https://pynative.com/python-mysql-blob-insert-retrieve-file-image-as-a-blob-in-mysql/ On Tue, May 18, 2021, 19:04 Chris <[email protected]> wrote: > 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 > <https://groups.google.com/d/msgid/web2py/30b99d7b-941c-4387-80cd-9f521399af82%40Canary?utm_medium=email&utm_source=footer> > . > -- 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/CADHCKLTUpqY99R9qfcgvJ7Thi9263LSbtD2XJx6NjEym-kLQgQ%40mail.gmail.com.

