Getting the "wrong" type generated with SQLAlchemy 0.7.8 and Oracle XE
Question: Can anyone please tell me why the DateTime type below creates a "DATE" object
and not a DateTime (or more appropriately, a TIMESTAMP type) as I have to
force the type as in the row below :

    
    
    #!/bin/python
    
    import sqlalchemy
    
    from sqlalchemy import Column, Integer, String, DateTime, Index, MetaData
    from sqlalchemy.ext.declarative import declarative_base
    from sqlalchemy.orm import relationship
    from sqlalchemy.orm import sessionmaker
    from sqlalchemy.dialects import oracle
    
    Base = declarative_base()
    
    import logging
    
    logging.basicConfig()
    logging.getLogger('sqlalchemy.engine').setLevel(logging.INFO)
    
    class TypeTest(Base):
        __tablename__ = "TYPETESTZ"
        thisisinteger = Column(Integer, primary_key = True)
        thisisnotadatetime = Column(DateTime)
        thisisdatetime = Column(oracle.TIMESTAMP)    
    
    if __name__ == "__main__":
        engine = sqlalchemy.create_engine('oracle://richard:password@xe')
        metadata = Base.metadata
        metadata.create_all(engine)
    

Log output:

    
    
    INFO:sqlalchemy.engine.base.Engine:SELECT USER FROM DUAL
    INFO:sqlalchemy.engine.base.Engine:{}
    INFO:sqlalchemy.engine.base.Engine:SELECT table_name FROM all_tables WHERE table_name = :name AND owner = :schema_name
    INFO:sqlalchemy.engine.base.Engine:{'name': u'TYPETESTZ', 'schema_name': u'RICHARD'}
    INFO:sqlalchemy.engine.base.Engine:
    CREATE TABLE "TYPETESTZ" (
        thisisinteger INTEGER NOT NULL, 
        thisisnotadatetime DATE, 
        thisisdatetime TIMESTAMP, 
        PRIMARY KEY (thisisinteger)
    )
    
    
    INFO:sqlalchemy.engine.base.Engine:{}
    INFO:sqlalchemy.engine.base.Engine:COMMIT
    


Answer: Oracle does not have a `DateTime` data type. In Oracle, a `Date` contains both
a day (i.e. August 21, 2012) and a time (i.e. 1:30 PM) with granularity of 1
second. A `Timestamp`, without additional qualifiers, merely allows you to
increase the granularity to nanoseconds (10^-9 seconds). It seems reasonable
for SQLAlchemy to translate a `DateTime` to an Oracle `Date` unless there is
some requirement that the `DateTime` supports fractional seconds (in which
case you would need a `Timestamp`) or time zones (in which case you would need
a `Timestamp with [local] time zone`).

