python - How to update table row with SQLAlchemy? -
i want update row of table.
to add used,
session.add(unit) #here unit unit object of class unit session.commit() to update tried,
session.merge(unit) session.commit() however, in database there other columns, e.g. create_by, created_on, updated_on, not set in unit object, these set null upon merge.
you can modify properties of class use represent row , call session.commit(). example:
# add new user user = user(name="john", age=20) session.add(user) session.commit() # modify user added user.age = 21 session.commit()
Comments
Post a Comment