Re: [SQLObject] DateTimeCol with microsecond resolution.
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: Petr J. <pet...@tp...> - 2011-02-01 19:09:34
|
> > I will give this a try, meanwhile I have created my own column type: > > -- > class ISO8601Validator(validators.Validator): > def from_python(self, value, state): > if value is not None: > value = value.strftime('%Y-%m-%d %H:%M:%S.%f') > return value > > def to_python(self, value, state): > if value is not None: > value = datetime.datetime.strptime(value, '%Y-%m-%d %H:%M:%S.%f') > return value > > class SOISO8601Col(SOStringCol): > def createValidators(self): > return [ISO8601Validator()] + \ > super(SOISO8601Col, self).createValidators() > > class ISO8601Col(StringCol): > baseClass = SOISO8601Col > -- > > If you want to go your own way, what about magic attributes? http://www.sqlobject.org/SQLObject.html#adding-magic-attributes-properties I think it is possible to store the time value as decimal and when in the time of reading you can convert it into the desired format. Regards Petr |