def convertValue(self, dbType, dataType, typeCode, value):
        logger.trace(
            "Converting \"%s\" to (%s, %s).", value, dataType, typeCode)
        if value is not None:
            if typeCode == NUMBER:
                try:
                    return NUMBER(value)
                except:
                    # Handle infinity and NaN for older ODBC drivers.
                    if value == "1.#INF":
                        return NUMBER('Infinity')
                    elif value == "-1.#INF":
                        return NUMBER('-Infinity')
                    else:
                        return NUMBER('NaN')
            elif typeCode == float:
                return value if not util.isString else float(value)
            elif typeCode == Timestamp:
                if util.isString(value):
                    return convertTimestamp(value)
                else:
                    return datetime.datetime.fromtimestamp(
                        value // SECS_IN_MILLISECS).replace(
                        microsecond=value % SECS_IN_MILLISECS *
                        MILLISECS_IN_MICROSECS)
            elif typeCode == Time:
                if util.isString(value):
                    return convertTime(value)
                else:
                    return datetime.datetime.fromtimestamp(
                        value // SECS_IN_MILLISECS).replace(
                        microsecond=value % SECS_IN_MILLISECS *
                        MILLISECS_IN_MICROSECS).time()
            elif typeCode == Date:
                if util.isString(value):
                    return convertDate(value)
                else:
                    return datetime.datetime.fromtimestamp(
                        value // SECS_IN_MILLISECS).replace(
                        microsecond=value % SECS_IN_MILLISECS *
                        MILLISECS_IN_MICROSECS).date()
            elif typeCode == BINARY:
                if util.isString(value):
                    return bytearray.fromhex(value)
            elif dataType.startswith("INTERVAL"):
                return convertInterval(dataType, value)
            elif dataType.startswith("JSON") and util.isString(value):
                return json.loads(value, parse_int=decimal.Decimal,
                                  parse_float=decimal.Decimal)
            elif dataType.startswith("PERIOD"):
                return convertPeriod(dataType, value)
        return value
Converts the value returned by the database into the desired
dataset/ETHPy150Open Teradata/PyTd/teradata/datatypes.py/DefaultDataTypeConverter.convertValue