내가 쓰는 방식으로

    fast api crud 만들기

    # create user = User( name="kim", age=1) db.add(user) db.commit() db.refresh(user) # read user_list = db.query(User) # update db_user = db.get(User, user.id) user_data = user.dict(exclude_unset=True) for key, value in user_data.items(): setattr(db_user, key, value) db.add(db_user) db.commit() db.refresh(db_user) # delete db.query(User).delete() db.commit()