https://github.com/metricq/aiocouch
🛋 An asynchronous client library for CouchDB 2.x and 3.x
https://github.com/metricq/aiocouch
asyncio couchdb library python3
Last synced: 8 months ago
JSON representation
🛋 An asynchronous client library for CouchDB 2.x and 3.x
- Host: GitHub
- URL: https://github.com/metricq/aiocouch
- Owner: metricq
- License: bsd-3-clause
- Created: 2019-06-11T13:18:29.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2024-08-16T11:59:18.000Z (almost 2 years ago)
- Last Synced: 2025-02-14T03:02:50.290Z (over 1 year ago)
- Topics: asyncio, couchdb, library, python3
- Language: Python
- Homepage: https://aiocouch.readthedocs.io/en/latest/
- Size: 301 KB
- Stars: 30
- Watchers: 5
- Forks: 10
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://opensource.org/licenses/BSD-3-Clause)
[](https://badge.fury.io/py/aiocouch)

[](https://codecov.io/gh/metricq/aiocouch)
[](https://aiocouch.readthedocs.io/en/latest/?badge=latest)
# aiocouch
An asynchronous client library for CouchDB 2.0 based on asyncio using aiohttp
## Key features
- All requests are asynchronus using aiohttp
- Supports CouchDB 2.x and 3.x
- Support for modern Python ≥ 3.7
## Library installation
```
pip install aiocouch
```
## Getting started
The following code retrieves and prints the list of `incredients` of the *apple_pie* `recipe`.
The `incredients` are stored as a list in the *apple_pie* `aiocouch.document.Document`,
which is part of the `recipe` `aiocouch.database.Database`. We use the context manager
`aiocouch.CouchDB` to create a new session.
```python
from aiocouch import CouchDB
async with CouchDB(
"http://localhost:5984", user="admin", password="admin"
) as couchdb:
db = await couchdb["recipes"]
doc = await db["apple_pie"]
print(doc["incredients"])
```
We can also create new recipes, for instance for some delicious cookies.
```python
new_doc = await db.create(
"cookies", data={"title": "Granny's cookies", "rating": "★★★★★"}
)
await new_doc.save()
```
For further details please refer to the documentation, which is available [here on readthedocs.org](https://aiocouch.readthedocs.io/).
## Run examples
- Setup the CouchDB URL and credentials using the environment variables
- Install dependencies using `pip install --editable '.[examples]'`
- run for instance `python examples/getting_started.py`
## Run tests
- Install dependencies using `pip install --editable '.[tests]'`
- Setup the CouchDB URL and credentials using the environment variables (`COUCHDB_HOST`, `COUCHDB_USER`, `COUCHDB_PASS`)
- run `pytest --cov=aiocouch`
## Generate documentation
- Install dependencies using `pip install '.[docs]'`
- switch to the `docs` directory: `cd docs`
- run `make html`