How to query a table for an object with the most recent table?
I have a table containing
class Ticker(Base): updated = Column('updated', DATETIME, index=False, nullable=False,primary_key=True) high = Column('high', FLOAT, index=False, nullable=False)
I'm trying to figure out how can I get an object with the last updated field? I am currently doing the following:
maxdate = db_session.query(func.max(Ticker.updated)).first()[0] Ticker.query.filter(Ticker.updated == maxdate).first()
I was wondering if there is a more efficient / shorter way to do this?
python sqlalchemy
Lucas kauffman
source share