This is the kind of thing I would love to find in a handy Web2py Cookbook! carlo
On 24 Mar, 14:27, Massimo Di Pierro <massimo.dipie...@gmail.com> wrote: > You can do it without if as well: > > db(query).update(...) or db.mytable.insert(...) > > On Mar 24, 8:26 am, Massimo Di Pierro <massimo.dipie...@gmail.com> > wrote: > > > To know if it exist or not you must have condition in the form of a > > query. You can do > > > if not db(query).update(...): db.mytable.insert(...) > > > where ... is the field='value' list. > > > On Mar 24, 4:46 am, Sergey Ozhigin <ser...@ozhigin.com> wrote: > > > > Hello, > > > > Is it possible in web2py to update or insert object (if doesn't exist) > > > to database in one command? > > > > Does anybody know an answer? > > > > wbr > >