The Couchbase Python SDK allows Python applications to access a Couchbase cluster. The Python SDK uses the high-performance C++ library Couchbase++ 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 4.0

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?

Moving from libcouchbase (LCB) to a Couchbase++ core brings Multi-Document, Distributed ACID Transactions to the Python SDK.

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.

Older SDK Versions

Documentation on older, unsupported versions of the SDK — that have reached end-of-life — can be found in the archive.