I don't know a good general solution for web2py, but if just targeting GAE: 1) request all existing products 2) find which of your products are new 3) insert new products in a single operation using the GAE API: db.put(list_of_models)
And if you have timeouts then break it up with Task Queues. On Sep 9, 4:37 pm, Miguel <goncalvesmig...@gmail.com> wrote: > Hi > > I have the following table: > db.define_table("products", > Field("categoryID", db.productCategory, writable=False, > readable=False, requires=IS_IN_DB(db, "productCategory.id", > "productCategory.name") ), # reference field > Field("productName", 'string',length=512, default=None), > Field("description", 'text',default=None) > ) > > - I have a list of (20000) rows that might contain products and I > would like to update my table. However some products might already be > in the db while others are completely new. > - I want to insert a row if it does not exist in the db (productName > could play the role of the identifier here) is already there AND > update a row in the case the product already exists in the DB> > > I can do it pretty easily if I go item by item and check if it already > exits in the db and then take the appropriate action (insert or > update). What I am looking for is the most efficient way to do this > (especially on GAE). > > thanks > Miguel