The Couchbase Python SDK allows Python applications to access a Couchbase cluster. The Python SDK offers a traditional synchronous API as well as integration with twisted, gevent, and asyncio. It depends on the C SDK, libcouchbase, (included automatically) which it uses for performance and reliability.

from twisted.internet import reactor
from txcouchbase.cluster import TxCluster

cluster = TxCluster('couchbase://localhost', ClusterOptions(PasswordAuthenticator('username', 'password')))
bucket = cluster.bucket("default")
cb = bucket.default_collection()

def on_upsert(ret):
    print("Set key. Result", ret)

def on_get(ret):
    print("Got key. Result", ret)

cb.upsert("key", "value").addCallback(on_upsert)

# Output:
# Set key. Result OperationResult<RC=0x0, Key=key, CAS=0x9a78cf56c08c0500>
# Got key. Result ValueResult<RC=0x0, Key=key, Value=u'value', CAS=0x9a78cf56c08c0500, Flags=0x0>

Couchbase Python SDK 3.0

Getting Started

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?

The Couchbase Python SDK 3.0 is a complete rewrite of the API, reducing the number of overloads to present a simplified surface area, and adding support for future Couchbase Server features like Collections and Scopes (available in Couchbase Server 6.5 & 6.6 as a developer preview).

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


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


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.