def update(self, cls, rid, partialrecord, user='<STR_LIT>'):
self.validate_partial_record(cls, partialrecord)<EOL>partialrecord[UPDATE_DATE] = self.nowstr()<EOL>partialrecord[UPDATER] = user<EOL>try:<EOL><INDENT>updatecount = self.db.update(cls, partialrecord, where={ID: rid})<EOL>if updatecount < <NUM_LIT:1>:<EOL><INDENT>raise KeyError('<STR_LIT>')<EOL><DEDENT><DEDENT>except (psycopg2.IntegrityError, psycopg2.ProgrammingError,<EOL>psycopg2.DataError) as error:<EOL><INDENT>if error.pgcode == psycopg2.errorcodes.UNIQUE_VIOLATION:<EOL><INDENT>raise KeyError('<STR_LIT>'.format(<EOL>cls, partialrecord[ID]))<EOL><DEDENT>elif error.pgcode == psycopg2.errorcodes.UNDEFINED_COLUMN:<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>else:<EOL><INDENT>raise ValueError('<STR_LIT>'.format(<EOL>psycopg2.errorcodes.lookup(error.pgcode)))<EOL><DEDENT><DEDENT>
Update existing record

        >>> s = teststore()
        >>> s.create('tstoretest', {'id': '1', 'name': 'Toto'})
        >>> r = s.get('tstoretest', '1')
        >>> r['age']
        >>> s.update('tstoretest', '1', {'age': 25})
        >>> r = s.get('tstoretest', '1')
        >>> r['age']
        25
        >>> s.update('tstoretest', '1', {'age': 30}, user='jane')
        >>> r = s.get('tstoretest', '1')
        >>> r[UPDATER]
        'jane'
        >>> s.update('tstoretest', '2', {'age': 25})
        Traceback (most recent call last):
            ...
        KeyError: 'No such record'
        >>> s.create('tstoretest', {'id': '2', 'name': 'Joe'})
        >>> s.update('tstoretest', '2', {'id': '1'})
        Traceback (most recent call last):
            ...
        KeyError: 'There is already a record for tstoretest/1'
        >>> s.update('tstoretest', '2', {'badcol': '1'})
        Traceback (most recent call last):
            ...
        ValueError: Undefined field
        >>> s.update('tstoretest', '2', {'age': 'hello'})
        Traceback (most recent call last):
            ...
        ValueError: Bad update (INVALID_TEXT_REPRESENTATION)