Updates the object by primary_key:

        .. code-block:: python

            DBSession.sacrud(Users).update(1, {'name': 'Petya'})
            DBSession.sacrud(Users).update('1', {'name': 'Petya'})
            DBSession.sacrud(User2Groups).update({'user_id': 4, 'group_id': 2},
                                                 {'group_id': 1})

        JSON support:

        .. code-block:: python

            DBSession.sacrud(Users).update(1, '{"name": "Petya"}')
            DBSession.sacrud(User2Groups).update(
                '{"user_id": 4, "group_id": 2}',    # primary_key
                '{"group_id": 1}'                   # data
            )

        Default it run ``session.commit() or transaction.commit()``.
        If it is not necessary use attribute ``commit=False``.

def update(self, pk, data, **kwargs):
        """
        Updates the object by primary_key:

        .. code-block:: python

            DBSession.sacrud(Users).update(1, {'name': 'Petya'})
            DBSession.sacrud(Users).update('1', {'name': 'Petya'})
            DBSession.sacrud(User2Groups).update({'user_id': 4, 'group_id': 2},
                                                 {'group_id': 1})

        JSON support:

        .. code-block:: python

            DBSession.sacrud(Users).update(1, '{"name": "Petya"}')
            DBSession.sacrud(User2Groups).update(
                '{"user_id": 4, "group_id": 2}',    # primary_key
                '{"group_id": 1}'                   # data
            )

        Default it run ``session.commit() or transaction.commit()``.
        If it is not necessary use attribute ``commit=False``.
        """
        pk = unjson(pk)
        data = unjson(data)
        obj = get_obj(self.session, self.table, pk)
        return self._add(obj, data, **kwargs)