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

Python SDK documentation, many fixes

    XMLWordPrintable

Details

    • Improvement
    • Status: Open
    • Major
    • Resolution: Unresolved
    • None
    • sdk3.2-backlog
    • None

    Description

      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 (127.0.0.1). 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 = '127.0.0.1'
      bucket_name = 'travel-sample'
      user = 'Administrator'
      password = 'password'

      cluster = Cluster('couchbase://

      {0}'.format(node))
      authenticator = PasswordAuthenticator(user, password)
      cluster.authenticate(authenticator)

      bucket = cluster.open_bucket(bucket_name)

      jfk_key = "airport_3797"

      document = bucket.get(jfk_key)

      print('Single document')
      print('{0}

      :

      {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

      Attachments

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

        Activity

          > Let's start using our travel-sample bucket in all the code examples.
          this is somewhat improved in CC 3.2 release docs.

          Good other points, adding to our post-3.2 epic.

          hakim.cassimally Hakim Cassimally added a comment - > Let's start using our travel-sample bucket in all the code examples. this is somewhat improved in CC 3.2 release docs. Good other points, adding to our post-3.2 epic.

          People

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

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes

                PagerDuty