Retrieving data from a bucket is also very easy. Adding onto the above example, you only add one more line. The entire snippit is included so you get the proper context:
from couchbase.couchbaseclient import VBucketAwareCouchbaseClient as client import uuid server = "http://localhost:8091/pools/default" v = client(server,"default","") for val in range(0,100): key = uuid.uuid4().bytes.encode('hex') setstatus = v.set(key, 0, 0, str(val)) getstatus = v.get(key) print setstatus print getstatus v.done()
Obviously, you can iterate through many get statements and print the status, but only one is shown as an example. The last key is used to retrieve the values from the bucket. Three values are returned from the get function and, in this case, are stored in the getstatus variable:
0 - User custom data flags
1 - CAS identifier, optionally used for future updates
2 - value of the document object