Search:

Search all manuals
Search this manual
Manual
Membase and Python Tutorial
Additional Resources
Community Wiki
Community Forums
Couchbase SDKs
Parent Section
4 Minimal Examples
Chapter Sections
Chapters

4.3. Retrieving Data

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: