Say you have

db.define_table('mytable',Field('file','upload'))

step 1: add a blob

db.define_table('mytable',Field('file','upload',uploadfield='fileblob'),Field('fileblob','blob')

step 2 move the data in blob:

for row in db(db.mytable).select():
    if row.file and not row.fileblob:
       data =
open(os.path.join(request.folder,'uploads',row.file),'rb').read()
       row.update_record(fileblob=data)
       db.commit()

Done

On Oct 14, 6:16 pm, Paul Gerrard <p...@gerrardconsulting.com> wrote:
> Hi all,
>
> I have the same requirement - moving a directory of upload files into
> the database. I was thinking the way to do it would be to copy the
> original table definition, then make the field changes to the table
> definitions, then write a script to process all the file-based records
> and post them into the new table. Sounds simple but probably isn't.
>
> Has anyone got a working script to do this perhaps?
>
> Paul.

Reply via email to