Minimal example using web2py DAL as a script. I'm not using firebird but
your example with the string shows that the storage in a blob is working in
firebird (Note that a python string is saved as binary data in a blob). In
a webapp, move code to model file and to a controller, or use a form to
upload an image, see
https://stackoverflow.com/questions/34999878/upload-image-in-web2py-to-database-from-default-controller-following-image-blog
from gluon import DAL,Field
>
> def testdb():
> uri = 'sqlite://storage.sqlite' # start of model code
>
> try:
> db_xml = DAL(uri,
> folder='test',
> check_reserved=['all'],
> migrate=True,
> fake_migrate=False,
> migrate_enabled=True,
> fake_migrate_all=False)
>
> except Exception as e:
> print "database {} could not be opened. {}".format(uri, e)
>
> db_xml.define_table('bin_files',
> Field('DATAblob', 'blob'),
> migrate=True
> )
> # controller code
> imgstream = open(u'/users/ncdegroot/pictures/pasfotos/photo.jpg', 'rb')
> bin_data = imgstream.read()
> stored_img = db_xml.bin_files.insert(DATAblob=bin_data)
> db_xml.commit() # needed in a script
> retrieved_img = db_xml(db_xml.bin_files.id==stored_img).select().first()
>
> assert retrieved_img.DATAblob == bin_data # the storage and retrieval
> worked
>
>
> if __name__ == "__main__":
> testdb()
>
>
2018-05-11 22:50 GMT+02:00 <[email protected]>:
> [email protected]
> <https://groups.google.com/forum/?utm_source=digest&utm_medium=email#!forum/web2py/topics>
> Google
> Groups
> <https://groups.google.com/forum/?utm_source=digest&utm_medium=email/#!overview>
> <https://groups.google.com/forum/?utm_source=digest&utm_medium=email/#!overview>
> Topic digest
> View all topics
> <https://groups.google.com/forum/?utm_source=digest&utm_medium=email#!forum/web2py/topics>
>
> - authentiction questions <#m_3708576762426783513_group_thread_0> - 1
> Update
> - link to a grid <#m_3708576762426783513_group_thread_1> - 2 Updates
> - Database question: 60 boolean fields + string:list or all
> string:list? <#m_3708576762426783513_group_thread_2> - 1 Update
> - Unexpected behaviour executing a query with DAL and record
> versioning enabled <#m_3708576762426783513_group_thread_3> - 1 Update
> - Insert data in firebird database
> <#m_3708576762426783513_group_thread_4> - 1 Update
>
> authentiction questions
> <http://groups.google.com/group/web2py/t/b8f3423b8f60e056?utm_source=digest&utm_medium=email>
> Dave S <[email protected]>: May 11 01:20PM -0700
>
> On Wednesday, May 9, 2018 at 10:20:24 PM UTC-7, Dave S wrote:
> >> out-of-the-box one via default/user.) Sometimes, it works on the first
> >> try.
>
> >> Q1: Why does the login often fail?
>
> No ideas out there?
>
>
> Back to top <#m_3708576762426783513_digest_top>
> link to a grid
> <http://groups.google.com/group/web2py/t/71bcf8007e27355d?utm_source=digest&utm_medium=email>
> Anthony <[email protected]>: May 10 05:06PM -0700
>
> The signature of the URL function is URL(a, c, f). If you pass only two
> arguments, it assumes they are c and f, and if you pass only one, it
> assumes it is f. You passed only 'static/Etichette', so it assumes that is
> the function and therefore uses the current application and controller. It
> should instead be:
>
> URL('static', 'Etichette', args=[row.etichetta])
>
> 'static' is a special value for the controller.
>
> Anthony
>
> On Thursday, May 10, 2018 at 6:59:45 AM UTC-4, Andrea Fae' wrote:
> Andrea Fae' <[email protected]>: May 11 10:12AM -0700
>
> ...I'm sorry...it was written in the book!! Sorry...I need to read again
> some parts of the book! Thank you
>
> Il giorno venerdì 11 maggio 2018 02:06:26 UTC+2, Anthony ha scritto:
> Back to top <#m_3708576762426783513_digest_top>
> Database question: 60 boolean fields + string:list or all string:list?
> <http://groups.google.com/group/web2py/t/4d4ee62a3dbac102?utm_source=digest&utm_medium=email>
> "Leonel Câmara" <[email protected]>: May 11 07:49AM -0700
>
> > On top of that the user will be able to add features not there, in a tag
> cloud format using string:list (I assume that's the best method for
> freeform data of this sort). So for example, you can add tags that say
> 420-friendly or piano
>
> There's your answer. Forget the 60 boolean fields and just have tags.
> Back to top <#m_3708576762426783513_digest_top>
> Unexpected behaviour executing a query with DAL and record versioning
> enabled
> <http://groups.google.com/group/web2py/t/6aa772c7392d5329?utm_source=digest&utm_medium=email>
> Awe <[email protected]>: May 11 07:24AM -0700
>
> Hello Leonel,
> opened this Issue on Mar 14,
> still no one assigned?
> Regards,
> Andreas
>
> Am Freitag, 9. März 2018 16:55:12 UTC+1 schrieb Leonel Câmara:
> Back to top <#m_3708576762426783513_digest_top>
> Insert data in firebird database
> <http://groups.google.com/group/web2py/t/fcc555bbd3c5d319?utm_source=digest&utm_medium=email>
> "Константин Комков" <[email protected]>: May 11 03:44AM -0700
>
> That 'example' isn't work too(((. Can anyone advice how can I insert data
> in blob field.
> There are one interesting thing. This code is working.
> db_xml.define_table('bin_files',
> Field('id','integer'),
> Field('PARENT'),
> Field('SRC_FILENAME'),
> Field('DATA', 'blob'),
> primarykey=['id','PARENT'],
> migrate=False
> )
>
> load_img = db_xml.bin_files.insert(PARENT=entrant_id[0][0],SRC_FILENAME=i.
> file,DATA='something')
> After this transaction I see 'c29tZXRoaW5n' in database - great!
> But when I trying load file it's don't work!
> filepath = os.path.join(request.folder,'uploads')
> img = db_app(db_app.doc_images.person=='{0} {1}
> {2}'.format(session.abit_f,
> session.abit_i,session.abit_o)).select()
> for i in img:
> stream=open(filepath + '\\' + i.file, 'rb')
> load_img = db_xml.bin_files.insert(PARENT=entrant_id[0][0],SRC_FILENAME=
> i.file,DATA=stream.read())
> Maybe anyone using Firebird 2.5 or have the same problem? Please, help.
> Back to top <#m_3708576762426783513_digest_top>
> You received this digest because you're subscribed to updates for this
> group. You can change your settings on the group membership page
> <https://groups.google.com/forum/?utm_source=digest&utm_medium=email#!forum/web2py/join>
> .
> To unsubscribe from this group and stop receiving emails from it send an
> email to [email protected].
>
--
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.