I'm using SQLAlchemy do read from a (given) SQLite database. Unfortunately the time value is String and not a TIMESTAMP like "Fri Apr 15 15:57:59 2016"
__tablename__ = 'test'
id = Column('id', String, primary_key=True)
time = Column('id', String)
I would recommend throwing a property on top of your model:
from datetime import datetime class Test(Base): __tablename__ = 'test' id = Column('id', String, primary_key=True) _time = Column('time', String) @property def time(self): return datetime.strptime(self._time, '%Y-%m-%d %H:%M')
Of course, you'll have to make sure that the format for
strptime is appropriate. But this way you'll be able to call
.time and get the appopriate timestamp.