I'm currently using this method to insert new elements. How can I update 
the 'update_date' field only if there's an update and only insert the 
'creation_date' one time?

import datetime

now = datetime.datetime.now()

db.define_table('dogs', Field('name'),
                                 Field('owner'),
                                 Field('address'),
                                 Field('creation_date', 'datetime'),
                                 Field('update_date', 'datetime'))


q1 = db.dogs.name == 'Paco'
q2 = db.dogs.owner == 'Rob'

db.dogs.update_or_insert((q1) & (q2), name='Paco', owner='Rob', 
creation_date=now)

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