Controller: def creategoodevent(): """ create a record with a string for the datetime field that is formatted like isoformat() i.e. '%Y-%m-%d %H:%M:%S.%f' """ dt_str = request.now.isoformat(' ') new_id = db.myevent.insert(name=dt_str, dt=dt_str, good='yes' ) return new_id
def createbadevent(): """ create a record with a string for the datetime field that is formatted like isoformat() i.e. '%Y-%m-%dT%H:%M:%S.%f' """ dt_str = request.now.isoformat() new_id = db.myevent.insert(name=dt_str, dt=dt_str, good='no' ) return new_id def readbadevents(): """ read the good events """ rows = db(db.myevent.good == 'no').select() return dict(rows = rows) def readgoodevents(): """ read the good events """ rows = db(db.myevent.good == 'yes').select() return dict(rows = rows) Model: db.define_table('myevent', Field('name', 'string'), Field('dt', 'datetime'), Field('good', 'string') ) On Sunday, February 15, 2015 at 12:40:46 PM UTC-8, Niphlod wrote: > > please show us your code (the one you're using for inserting the value), > and the model... so we can track down the anomaly > > On Friday, February 13, 2015 at 12:31:44 AM UTC+1, MDSIII wrote: >> >> I'm inserting a row with a value for a datetime type field such as >> '2015-02-12T14:43:52.113000'. >> >> The DAL lets me do the insert but errors in the adapter when I do a >> select that includes this row/column. >> >> I realize the string does not match the datetime.isoformat(' ') that the >> dbapi adapter expects on read but why doesn't it also do validation on >> write. >> >> I suspect the answer is to do my own type checking or leverage default >> SQLFORM validator? >> >> Thanks, >> Max >> > -- 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 web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.