The Couchbase Python SDK allows Python applications to access a Couchbase cluster. The Python SDK uses the high-performance C library libcouchbase to handle communicating to the cluster over Couchbase’s binary protocols.

from couchbase.cluster import Cluster
from couchbase.auth import PasswordAuthenticator

cluster = Cluster('couchbase://localhost', authenticator=PasswordAuthenticator('username', 'password'))
bucket = cluster.bucket('default')
coll = bucket.default_collection()


coll.upsert('key', 'value')
get_res = coll.get("key")
print('Get result - value: {}; CAS: {}'.format(get_res.content, get_res.cas))

# Output:
# Get result - value: value; CAS: 1617046112012992512

Couchbase Python SDK 3.2

Getting Started

Dive right in with a quick install and Hello World. Try out our Travel Sample Application. And take a look at the developer preview of Collections.

Practical Howto Docs

Connect to our services — data (KV); Query; Search; Analytics — and the Sub-Document API.

Reference Guides

The documentation supplements the practical Howto docs with references and concept guides, for those who prefer a broader understanding before diving in and coding.

What’s Hot?

Leverage the new Couchbase Server Scopes and Collection features to build multi-tenant micro-service application. Add an additional layer of security and protect your sensitive workloads using our Client Side Field Level Encryption capability.

The 3.x Python SDK introduces comprehensive PEP-484-style type annotations.

About

Those useful nuts-and-bolts guides to compatibility tables; release notes; contribution guide; and the migration guide for moving to the 3.x API.

Community

For community help, visit the Couchbase forums. The Python SDK can be combined with many other projects in the broader JavaScript ecosystem and beyond — in the Couchbase Blog there are several examples.