Uploaded image for project: 'Couchbase Documentation'
  1. Couchbase Documentation
  2. DOC-6700

Python SDK documentation, many fixes




      Ok, where do I start?

      In the first paragraph, we mention the method get_in(), that does not exist in the SDK. There is lookup_in(), which we show an example for later.

      The page misses the connection to cluster part. Anyone who comes to this page to learn about document operations should get the copy/paste/save/run quality of code snippets. Unfortunately, most of our code examples for all SDKs are not there yet. So, please add the connect to cluster, authenticate, and open bucket parts.

      On this page, we refer to an open bucket by "bucket", "bkt", and "cb" object names. Can we please have some consistency?

      Let's start using our travel-sample bucket in all the code examples. And let's start stating it at the top of the page, before all the code snippets:

      "For all the code examples below, we assume that you have a local installation of Couchbase Server ( We assume that the cluster was configured with 'Administrator' account (case-sensitive!) with 'password' being the account password. We also assume that you have installed on your cluster the travel-sample bucket included with every Couchbase Serve installation [link to travel-sample installation page]"

      Here is the working code to show the readers some of the read operations with Python SDK:


      from couchbase.cluster import Cluster
      from couchbase.cluster import PasswordAuthenticator
      import couchbase.subdocument as SubDoc

      node = ''
      bucket_name = 'travel-sample'
      user = 'Administrator'
      password = 'password'

      cluster = Cluster('couchbase://

      authenticator = PasswordAuthenticator(user, password)

      bucket = cluster.open_bucket(bucket_name)

      jfk_key = "airport_3797"

      document = bucket.get(jfk_key)

      print('Single document')


      {1}'.format(jfk_key, document.value))

      nyc_keys = ["airport_3797", "airport_3697", "airport_3993"]

      nyc_airports = bucket.get_multi(nyc_keys)

      print('\nMultiple documents')

      for key, item in nyc_airports.items():
      print('{0}: {1.value}'.format(key, item))

      jfk_lat = bucket.lookup_in(jfk_key, SubDoc.get('geo.lat'))

      print('\nSub-document value')
      print('{0}: {1}

      '.format('JFK latitude', jfk_lat[0]))


      Reporter: Oleg Kuzmin
      E-mail: oleg.kuzmin@couchbase.com


        No reviews matched the request. Check your Options in the drop-down menu of this sections header.



            hakim.cassimally Hakim Cassimally
            oleg.kuzmin Oleg Kuzmin (Inactive)
            0 Vote for this issue
            2 Start watching this issue



              Gerrit Reviews

                There are no open Gerrit changes