Search:

Search all manuals
Search this manual
Manual
Couchbase Client Library: Python 1.0
Community Wiki and Resources
Download Client Library
Python Client Library
SDK Forum
Additional Resources
Community Wiki
Community Forums
Couchbase SDKs
Parent Section
6 Update Operations
Chapter Sections
Chapters

6.1. Append Methods

The append() methods allow you to add information to an existing key/value pair in the database. You can use this to add information to a string or other data after the existing data.

The append() methods append raw serialized data on to the end of the existing data in the key. If you have previously stored a serialized object into Couchbase and then use append, the content of the serialized object will not be extended. For example, adding Dictionary of integers into the database, and then using append() to add another integer will result in the key referring to a serialized version of the dictionary, immediately followed by a serialized version of the integer. It will not contain an updated dictionary with the new integer appended to it. De-serialization of objects that have had data appended may result in data corruption.

API Callobject.append(key, value [, casunique ])
Asynchronousno
Description Append a value to an existing key
Returnsobject ( Binary object )
Arguments 
key Document ID used to identify the value
object value Value to be stored
int casunique Unique value used to verify a key/value combination

The append() appends information to the end of an existing key/value pair. The append() function requires a CAS value.

For example, to append a string to an existing key, first get the value for the given key, then use the first element in the returned list as the CAS:

casv = couchbase.get("samplekey")
couchbase.append(casv[0],"samplekey", "appendedstring")