I found only one working example.
tables.py
db_xml.define_table('bin_files',
Field('id','integer'),
Field('PARENT'),
Field('SRC_FILENAME'),
Field('DATA', 'blob'),
primarykey=['id','PARENT'],
migrate=False
)
default.py
img = db_app(db_app.doc_images.person=='{0} {1}
{2}'.format(session.abit_f,session.abit_i,session.abit_o)).select(db_app.doc_images.file)
filepath = os.path.join(request.folder,'uploads')
for i in img:
stream=open(filepath + '\\' + i.file, 'rb')
s=base64.encodestring(stream.read())
db_xml.executesql("""INSERT INTO bin_files
(PARENT,SRC_FILENAME,DATA) VALUES
({0},'{1}','{2}')""".format(entrant_id[0][0],i.file,s))
db_xml.commit()
I don't know how can I create the generator and trigger in web2py for using
insert like this.
db_xml.bin_files.insert(PARENT=entrant_id[0][0],SRC_FILENAME=i.file,DATA=stream.read())
--
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.