Return a list of entries in the table or single
        entry if there is an pk.

        .. code-block:: python

            # All users
            DBSession.sacrud(Users).read()

            # Composite primary_key
            DBSession.sacrud(User2Groups).read({'user_id': 4, 'group_id': 2})

            # Multiple rows
            primary_keys = [
                {'user_id': 4, 'group_id': 2},
                {'user_id': 4, 'group_id': 3},
                {'user_id': 1, 'group_id': 1},
                {'user_id': 19, 'group_id': 2}
            ]
            DBSession.sacrud(User2Groups).read(*primary_keys)

            # JSON using
            primary_keys = '''[
                {"user_id": 4, "group_id": 2},
                {"user_id": 4, "group_id": 3},
                {"user_id": 1, "group_id": 1},
                {"user_id": 19, "group_id": 2}
            ]'''
            DBSession.sacrud(User2Groups).read(primary_keys)

            # Delete
            DBSession.sacrud(User2Groups).read(*primary_keys)\
                .delete(synchronize_session=False)

            # Same, but work with only not composite primary key
            DBSession.sacrud(Users).read((5, 10))       # as list
            DBSession.sacrud(Users).read('[5, 10]')     # as JSON
            DBSession.sacrud(Users).read('{"id": 5}')   # as JSON explicit pk
            DBSession.sacrud(Users).read(5, "1", 2)     # as *args
            DBSession.sacrud(Users).read(42)            # single

def read(self, *pk):
        """
        Return a list of entries in the table or single
        entry if there is an pk.

        .. code-block:: python

            # All users
            DBSession.sacrud(Users).read()

            # Composite primary_key
            DBSession.sacrud(User2Groups).read({'user_id': 4, 'group_id': 2})

            # Multiple rows
            primary_keys = [
                {'user_id': 4, 'group_id': 2},
                {'user_id': 4, 'group_id': 3},
                {'user_id': 1, 'group_id': 1},
                {'user_id': 19, 'group_id': 2}
            ]
            DBSession.sacrud(User2Groups).read(*primary_keys)

            # JSON using
            primary_keys = '''[
                {"user_id": 4, "group_id": 2},
                {"user_id": 4, "group_id": 3},
                {"user_id": 1, "group_id": 1},
                {"user_id": 19, "group_id": 2}
            ]'''
            DBSession.sacrud(User2Groups).read(primary_keys)

            # Delete
            DBSession.sacrud(User2Groups).read(*primary_keys)\
                .delete(synchronize_session=False)

            # Same, but work with only not composite primary key
            DBSession.sacrud(Users).read((5, 10))       # as list
            DBSession.sacrud(Users).read('[5, 10]')     # as JSON
            DBSession.sacrud(Users).read('{"id": 5}')   # as JSON explicit pk
            DBSession.sacrud(Users).read(5, "1", 2)     # as *args
            DBSession.sacrud(Users).read(42)            # single
        """
        pk = [unjson(obj) for obj in pk]

        if len(pk) == 1:  # like ([1,2,3,4,5], )
            return get_obj(self.session, self.table, pk[0])
        elif len(pk) > 1:  # like (1, 2, 3, 4, 5)
            return get_obj(self.session, self.table, pk)
        return self.session.query(self.table)