class TimeStamp(sa_types.TypeDecorator): """Represents datetime/time timestamp object as a bigint value. Despite the fact that timestamp objects are represented by float value in python, the Float column cannot be used for storing such values, since timestamps values can be bigger than the limit of Float columns at some back-ends (the value will be cropped in such case). Also, using DateTime type is not convenient too, since it do not accurate with microseconds. """ impl = sa_types.BigInteger _coefficient = 1000000.0 def process_bind_param(self, value, dialect): if value is None: return None return value * self._coefficient def process_result_value(self, value, dialect): if value is None: return None return value / self._coefficient def coerce_compared_value(self, op, value): if isinstance(value, int): return sa_types.BigInteger() else: return self