[Python] How to offset by 1 year the values of a date column using ORM?

Discussão em 'Python' iniciado por Stack, Março 13, 2025.

  1. Stack

    Stack Membro Participativo

    I have an sqlalchemy ORM for a Postgres table:

    class Item(Base, BoilerPlateMixinBase):
    id = Column(Integer, primary_key=True)
    date = Column(Date)
    value = Column(Float)


    What's the quickest way to experiment having all the dates offset by 1 year?

    I could do that by modifying either:

    • the records in the table
    • the lines of code that read the records
    • the ORM date column

    The latter is preferable as it'd require changing just one place in the code.

    But how can this be achieved?

    (tried DATEADD as suggested here, but didn't work for me. sqlalchemy 2.0)

    Continue reading...

Compartilhe esta Página