def typeCheckAndConvert(self, val, aname, attr): #nulls always allowed (unless the db says no) if val is None: return val if _isDateKind(attr): if not (Date.isDateTime(val) or val is SYSDATE): val = DateTime.DateTimeFrom(val) val = _dateConvertToDB(val, attr) elif (_isNumber(attr) and not isinstance(val, types.FloatType) and not isinstance(val, types.IntType)): raise TypeError, ('trying to assign %s to %s and is not' ' a number') % (val, aname) elif _isString(attr) and not isinstance(val, types.StringType): raise TypeError, 'trying to assign %s to %s and is not a string' % ( val, aname) return val
def _dateConvertFromDB(item): if item is None: return item # MySQLdb will now return DateTime objects is egenix is present. if type(item) == DateTime.DateTimeType: return item if string.find(item, '-') == -1: #timestamp form y = item[:4] mo = item[4:6] d = item[6:8] h = item[8:10] mi = item[10:12] s = item[12:14] else: y = item[:4] mo = item[5:7] d = item[8:10] h = item[11:13] mi = item[14:16] s = item[17:19] return DateTime.DateTime(int(y), int(mo), int(d), int(h), int(mi), int(s))
def _dateConvertFromDB(dbd): return DateTime.localtime(dbd)
def _dateConvertToDB(dt): if dt == PyDBI.SYSDATE: dt = DateTime.now() return '%04d%02d%02d%02d%02d%02d' % (dt.year, dt.month, dt.day, dt.hour, dt.minute, dt.second)
def _dateConvertFromDB(val, type): if val is None: # DateTimeFrom can't handle None as an argument return None return DateTime.DateTimeFrom(sapdbapi.valTranslation[type](val))
def _dateConvertFromDB(val, type): return DateTime.DateTimeFrom(sapdbapi.valTranslation[type](val))