couchdb-python
Python SDK for Apache CouchDB 3.x. It comes as two packages, both published together as couchdb-sdk on PyPI:
| Package | What it is | Edited by |
|---|---|---|
couchdb_sdk |
Idiomatic client: dict-like documents, automatic _rev tracking, typed errors, conflict retries |
hand-written |
couchdb_client |
Low-level client generated from couchdb-openapi (API docs) | generated, don't edit |
Quick start
from couchdb_sdk import CouchDB, Conflict
with CouchDB("http://localhost:5984", "admin", "password") as couch:
db = couch.create_database("people")
db["alice"] = {"age": 30} # create
alice = db["alice"] # read -> dict with _id/_rev
alice["age"] = 31
db.save(alice) # update; alice["_rev"] is refreshed
db.update("alice", lambda d: {**d, "age": d["age"] + 1}) # retries on 409
db.bulk_save([{"age": a} for a in (20, 40, 50)])
db.create_index(["age"], name="age-idx")
older = db.find({"age": {"$gt": 30}}, sort=[{"age": "desc"}]).docs
db.save_design("stats", {"by_age": {"map": "function(d){ emit(d.age, 1); }", "reduce": "_count"}})
db.view("stats", "by_age")
db.put_attachment("alice", "avatar.png", open("avatar.png", "rb").read(), "image/png")
page = db.changes(since="0", doc_ids=["alice"])
for change in db.follow(checkpoint="indexer", include_docs=True):
... # retries transient errors; resumes from _local/indexer after restart
couch.replicate("people", "people_backup", create_target=True)
# Replication building blocks, for writing your own sync
db.revs_diff({"alice": [alice["_rev"]]}) # revisions the db is missing
db.bulk_get([{"id": "alice"}], revs=True) # docs with _revisions
db.bulk_save(docs_with_revisions, new_edits=False) # keep the given _rev ids
login() keeps the cookie session alive: it takes the renewed cookie CouchDB
sends and logs in again once if the session expires.
Housekeeping and cheap checks:
db.head("alice") # current rev without the body, or None
db.get_if_changed("alice", rev) # None if unchanged (ETag / 304)
db.explain({"age": {"$gt": 30}}) # which index a query uses
db.purge({"alice": [rev]}) # remove revisions for good
db.compact(); db.view_cleanup()
couch.dbs_info(["people", "other"]); couch.active_tasks(); couch.db_updates(feed="longpoll")
Errors are typed: NotFound (also a KeyError), Conflict, Unauthorized,
Forbidden, PreconditionFailed, all subclasses of CouchDBError with
.status, .error and .reason.
Need an endpoint the wrapper doesn't cover? Use the generated client directly:
couchdb_client.DocumentsApi(couch.client).
Repository layout
couchdb_client/ generated; regenerated by couchdb-sdk-generator PRs
couchdb_sdk/ hand-written idiomatic layer
tests/ pytest: unit + integration (real CouchDB)
conformance/ Gauge step implementations for the shared cross-SDK suite
scripts/conformance.sh runs the shared suite from couchdb-sdk-generator
Files the generator must not touch are listed in .openapi-generator-ignore.
Testing
Both suites need a CouchDB server:
docker run -d --name couchdb -p 5984:5984 -e COUCHDB_USER=admin -e COUCHDB_PASSWORD=password couchdb:3.4
for db in _users _replicator _global_changes; do curl -X PUT http://admin:password@localhost:5984/$db; done
python -m venv .venv && .venv/Scripts/activate # or: source .venv/bin/activate
pip install -e . -r test-requirements.txt
pytest tests # unit + integration
bash scripts/conformance.sh # Gauge conformance (needs Node; specs from ../couchdb-sdk-generator)
bash scripts/conformance.sh --tags documents # one area
Override the server with COUCHDB_URL, COUCHDB_USER and COUCHDB_PASSWORD.
Versioning
The package version is the spec's info.version, stamped at generation time.
.generated-from records the exact spec and generator commits.
Roadmap
Planned fixes and features are in ROADMAP.md.
License
Metadata
Release files for couchdb-sdk 0.7.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| couchdb_sdk-0.7.0.tar.gz | 80.7 kB | With provenance | Details for couchdb_sdk-0.7.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| couchdb_sdk-0.7.0-py3-none-any.whl | Python 3 | none | any | Details for couchdb_sdk-0.7.0-py3-none-any.whl |
Total release size: 260.1 kB
Release files / couchdb_sdk-0.7.0.tar.gz
| Download URL | couchdb_sdk-0.7.0.tar.gz |
|---|---|
| Size | 80.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
030b593a58fa76bb79e6ab7f41a354fdc65df47fd45010eef93129f214d9cb63
|
|
BLAKE2b-256 checksum How to use checksums |
e98c6f1a706ced3376730dcb50830012f344e653a03a945ec5601ef73e28b2dd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 28, 2026.
Transparency logRelease files / couchdb_sdk-0.7.0-py3-none-any.whl
| Download URL | couchdb_sdk-0.7.0-py3-none-any.whl |
|---|---|
| Size | 179.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b9d053991423e20eb61b4af2b09f9496e95e1f6c5efd389d9a5931544775a76b
|
|
BLAKE2b-256 checksum How to use checksums |
8b3719432115d4df966841b1f0338ef62c2371acc238591c0863341d671bfc26
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 28, 2026.
Transparency logSecurity for couchdb-sdk 0.7.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for couchdb_sdk-0.7.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 28, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.