def __unicode__(self): value = self.value if value is None: return 'null' if isinstance(value, bool): return value and '1' or '0' if isinstance(value, (int, long, float, Decimal)): return str(value) if isinstance(value, basestring): return self.quote_str(value) if isinstance(value, datetime): return self.quote_str(datetime2timestamp(value)) if isinstance(value, date): return self.quote_str(str(value)) if isinstance(value, buffer): return "X'%s'" % hexlify(value) assert False, value
def __unicode__(self): value = self.value if value is None: return 'null' if isinstance(value, bool): return value and '1' or '0' if isinstance(value, basestring): return self.quote_str(value) if isinstance(value, datetime): return self.quote_str(datetime2timestamp(value)) if isinstance(value, date): return self.quote_str(str(value)) if PY2: if isinstance(value, (int, long, float, Decimal)): return str(value) if isinstance(value, buffer): return "X'%s'" % hexlify(value) else: if isinstance(value, (int, float, Decimal)): return str(value) if isinstance(value, bytes): return "X'%s'" % hexlify(value).decode('ascii') assert False, value # pragma: no cover
def py2sql(converter, val): return datetime2timestamp(val)