0

Can you help me to solve following problem? i have table in sqlalchemy ORM (Python)

    class Item(Base):
       __tablename__='items'
       id = Column(Integer,primary_key=True)
       title = Column(String)

    class Stat(Base):
       __tablename__='stats'
       id = Column(Integer,primary_key=True)
       item_id = Column(Integer,ForeignKey('items.id'))
       price = Column(Float)
       date = column(Date)

I want to get column "diff" computing price difference between rows of current and former dates of Stat table. How can i implement it?

I took a look at similar questions (SQL Server DATEDIFF Computed Column Between Rows, Compare difference between two columns in SQLAlchemy ORM). So which way do you think is more suitable? Creating a view, events or something else?

0 Answers0