On Mon, Jul 30, 2012 at 12:11 AM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> Sorry. My advice was about downloading all tabes at once.
>
> If you want import one table you could do:
>
> def import_table():
>     form = SQLFORM.factory(Field('table',requires=IS_IN_SET(db.tables)),
>
>  Field('csvfile','upload',uploadfield=False))
>     form.process()
>     if form.accepted:
>           try:
>
> db[form.vars.table].import_from_csv_file(request.vars.csvfile)
>           except: form.errors.csvfile = 'invalid file'
>     return dict(form=form)
>

I tried that on Windows, and the upload field gave an open command, so I
right-clicked "New File->New Text Document" and create "foo.csv".

Selecting it then clicking open then clicking "Submit" gave me the "invalid
file" error.

On Sunday, 29 July 2012 07:18:02 UTC-5, Hassan Alnatour wrote:
>>
>> Thank you a lot massimo  but what is tempfile and how can i give it
>> a certain  table to import ??
>>
>>
>> Best Regards,
>>
>>
>> On Sun, Jul 29, 2012 at 5:14 AM, Massimo Di Pierro <
>> massimo.dipie...@gmail.com> wrote:
>>
>>> In view:
>>> <a href="{{=URL('download_all')}}**">download all</a>
>>>
>>> In controller
>>>
>>> def download_all():
>>>     import tempfile
>>>     tmp = tempfile.TemporaryFile()
>>>     db.export_to_csv_file(tmp)
>>>     tmp.seek(0)
>>>     return response.stream(tmp)
>>>
>>> On Sunday, 29 July 2012 03:07:40 UTC-5, Hassan Alnatour wrote:
>>>>
>>>> Dear ALL,
>>>>
>>>> How can i make a button that lets the user download a scv file for on
>>>> of my tables ?
>>>>
>>>>
>>>> best regards,
>>>>
>>>  --
>>>
>>>
>>>
>>>
>>
>>  --
>
>
>
>

-- 



Reply via email to