Philosophy

Cloudant-Python is minimal, performant, and effortless. Check it out:

Pythonisms

Cloudant and CouchDB expose REST APIs that map easily into native Python objects. As much as possible, Cloudant-Python uses native Python objects as shortcuts to the raw API, so that such convenience never obscures what's going on underneath. For example:

Cloudant-Python expose raw interactions -- HTTP requests, etc. -- through special methods, so we provide syntactical sugar without obscuring the underlying API. Built-ins, such as __getitem__, act as Pythonic shortcuts to those methods. For example:

Iterate over Indexes

import cloudant
account = cloudant.Account('garbados')
db = account.database('test')
view = db.all_docs() # returns all docs in the database
for doc in db:
# iterates over every doc in the database
pass
for doc in view:
# and so does this!
pass
for doc in view.iter(descending=True):
# use `iter` to pass options to a view and then iterate over them
pass

Behind the scenes, Cloudant-Python yields documents only as you consume them, so you only load into memory the documents you're using.

Special Endpoints

If CouchDB has a special endpoint for something, it's in Cloudant-Python as a special method, so any special circumstances are taken care of automagically. As a rule, any endpoint like _METHOD is in Cloudant-Python as Object.METHOD. For example:

Asynchronous

If you instantiate an object with the async=True option, its HTTP request methods (such as get and post) will return Future objects, which represent an eventual response. This allows your code to keep executing while the request is off doing its business in cyberspace. To get the Response object (waiting until it arrives if necessary) use the result method, like so:

As a result, any methods which must make an HTTP request return a Future object.

Option Inheritance

If you use one object to create another, the child will inherit the parents' settings. So, you can create a Database object explicitly, or use Account.database to inherit cookies and other settings from the Account object. For example: