0

I have a PostgreSQL table defined in my model class as:

    class Interruption(Base):
    __tablename__ = "tbl_interruptions"

    id = Column(Integer, primary_key=True, nullable=False)
    title = Column(String, unique=True, nullable=False)
    file_link = Column(String, nullable=False)
    created_at = Column(TIMESTAMP(timezone=True), nullable=False, server_default=text('Now()'))
    is_downloaded = Column(Boolean, default=False)
    is_extracted = Column(Boolean, default=False)

The create & get queries are working fine but updates don't work. When I try to update the is_downloaded column it doesn't work. The query returns 1 meaning the action has been accomplished in the DB but the value doesn't update. Below is the update snippet:

def update_interruption_download_status(db: Session, status: bool, interruption_id: int):
    return (db.query(models.Interruption).filter(models.Interruption.id == interruption_id)
            .update({models.Interruption.is_downloaded: status}))

I've tried to change the column type to int but it still doesn't work. Kindly assist.

0

1 Answer 1

0

Oopsies, I didn't know I had to commit. I just added db.commit() and now it works :-)

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.