Git Product home page Git Product logo

aiocouch's Introduction

License PyPI version Python package codecov Documentation Status

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.

    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.

        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.

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

aiocouch's People

Contributors

adeelsohailahmed avatar adrienverge avatar bmario avatar bravier avatar h--o-l avatar kinnarr avatar phijor avatar tilsche avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.