Thanks Anthony but in any case I've got the same web2py answer:
'DAL' object has no attribute 'products'

How is it possible ?

Il giorno lunedì 9 dicembre 2013 17:03:54 UTC+1, Anthony ha scritto:
>
> I think you want db.products.truncate(), not db.products.drop().
>
> Anthony
>
> On Monday, December 9, 2013 8:03:24 AM UTC-5, Gael Princivalle wrote:
>>
>> Hello all.
>>
>> I need to import in one table data keeping original id's.
>> I know that I have to drop the table first, but when I want to import the 
>> CSVfile web2py say me that "<type 'exceptions.AttributeError'> 'DAL' object 
>> has no attribute 'products' 
>> I've tried to follow these instructions:
>>
>> http://web2py.com/books/default/chapter/30/06/lastrazione-del-database?search=import_from_csv_file
>> And also here:
>>
>> https://groups.google.com/forum/#!searchin/web2py/id_map{}/web2py/tURuX_Yyr2k/tzOzB4mGVkQJ
>>
>> In my csv file I have:
>> products.id,products.code,products.description
>> 407,040525,DA 9-24
>> 408,040586,DR 14-37
>>
>> Here is my db:
>> db.define_table('products',
>>                 Field('code', unique=True),
>>                 Field('description'),,
>>                 format='%(code)s')
>> db.define_table('csv_products_files',
>>                 Field('csv_file', 'upload', requires = IS_NOT_EMPTY()),
>>                 auth.signature)
>>
>> My controller:
>> def import_products():
>>     form=SQLFORM(db.csv_products_files)
>>     if form.process().accepted:
>>         response.flash = 'Form accepted'
>>         db.products.drop()
>>         db.products.import_from_csv_file(open(form.vars.csv_file, 'r', 
>> id_map={}))
>>     elif form.errors:
>>         response.flash = 'Form has errors'
>>     return locals()
>>
>> Someone knows how I can resolve it ?
>>
>> Thanks.
>>
>

-- 
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/groups/opt_out.

Reply via email to