Oracle does not return datetime objects for timestamps in python 2.3

Issue #542 resolved
Former user created an issue

Because of the way that the oracle driver works in python 2.3 OracleTimestamp objects are returned by oracle instead of real datetime objects. Although they have the same attributes as datetime objects, they lack many of the methods. To fix this I have added the following to oracle.py.

class OracleDateTime(sqltypes.DateTime): def get_col_spec(self): return "DATE"

def convert_result_value(self, value, dialect):
    if value is None or isinstance(value,datetime.datetime):
        return value
    else :
        return datetime.datetime(value.year,value.month,
                                 value.day,value.hour,
                                 value.minute, value.second)

class OracleTimestamp(sqltypes.DateTime): def get_col_spec(self): return "TIMESTAMP"

def get_dbapi_type(self, dialect):
    return dialect.TIMESTAMP

def convert_result_value(self, value, dialect):
    if value is None or isinstance(value,datetime.datetime):
        return value
    else :
        return datetime.datetime(value.year,value.month,
                                 value.day,value.hour,
                                 value.minute, value.second)

Comments (3)

  1. Log in to comment