Thanks for the response Leonel!

On Wednesday, July 25, 2018 at 12:25:50 AM UTC+8, Leonel Câmara wrote:
>
> Ideally you would save the id_map from the first time you imported, you 
> can then supply the same id_map to the import_from_csv_file function so it 
> would update the records instead of inserting new ones. To save the id_map 
> you can do something like this the first time you import
>
> my_map = {}
>
> db.your_table.import_from_csv(csvfile, my_map) 
>
> pickle.dump(my_map, pickle_file) # example of how to save id_map
>
>
> Now my_map will hold the map, you can save it, for instance, using pickle. 
> Next time you want to re-import the file with updates you can load the 
> pickled my_map and use that as id_map. Ideally you would test for the 
> pickle's file existence before doing it, and if you want to be absolutely 
> sure you will use portalocker to avoid having more than one process trying 
> to do imports and changing the pickled id_map.
>

-- 
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.

Reply via email to