Skip to content

# Update

#### Select query

        duck = Duck.query.filter_by(name=name).first()
        duck.duck_type_id = duck_type_id
        db.session.commit()

#### Init

        new_duck = Duck("name": name, "duck_type_id": duck_type_id)
        db.session.merge(new_duck)
        db.session.commit()

or

        attr = {
            "name": name,
            "duck_type_id": duck_type_id,
        }
        duck = Duck(**attr)
        db.session.merge(new_duck)
        db.session.commit()

#### Init and update

    new_duck = Duck()
    new_duck.name = name
    new_duck.duck_type_id = duck_type_id
    db.session.merge(new_duck)
    db.session.commit()