CouchDB python framework
Python Other
Latest commit 6be1486 Oct 16, 2015 @benoitc Merge pull request #185 from snopoke/patch-1
Django 1.7 get_verbose_name
Failed to load latest commit information.
couchdbkit Django 1.7 get_verbose_name Dec 5, 2014
debian typo Feb 20, 2011
doc/ sync doc May 4, 2012
examples Add a bit more detailed django app example Jan 26, 2014
tests bring back lenient wrapping unless classes is explicitly set Sep 13, 2013
.gitignore ease document loading, add gitignore, remove pyc* Mar 2, 2010
.hgignore don't commit test db Nov 11, 2009
.hgtags Added tag 0.4.2 for changeset 631c681601e1 Feb 4, 2010
.travis.yml fix travis tests Feb 9, 2013
LICENSE say hello to 2012 Jun 6, 2012
NOTICE say hello to 2012 Jun 6, 2012
THANKS add Daniel Roberts & Rémy Hubscherto THANKS Feb 9, 2013
TODO.txt update todo Jan 8, 2010
requirements.txt bump requirements Aug 30, 2013
setup.cfg add coverage and ignore django during tests Apr 2, 2010 bump requirements Aug 30, 2013



Couchdbkit provides you a full featured and easy client to access and manage CouchDB. It allows you to manage a CouchDBserver, databases, doc managements and view access. All objects mostly reflect python objects for convenience. Server and Databases objects could be used for example as easy as using a dict.

Build Status


Couchdbkit requires Python 2.x superior to 2.6.

To install couchdbkit using pip you must make sure you have a recent version of distribute installed:

$ curl -O
$ sudo python
$ easy_install pip

To install or upgrade to the latest released version of couchdbkit:

$ pip install couchdbkit

Getting started

This tutorial exposes key features of this library mainly through code examples. For in-depth description of the modules, you'll want to read the API documentation.

Write your first CouchDB document

from couchdbkit import Server
# server object
server = Server()

# create database
db = server.get_or_create_db("greeting")

doc = {"mydoc": "test"}
import datetime
from couchdbkit import *

class Greeting(Document):
    author = StringProperty()
    content = StringProperty()
    date = DateTimeProperty()

Store the submitted Greetings

Here is the code to save a greet on Greeting database. We also see how to create a database:

from couchdbkit import Server

# associate Greeting to the db

# create a new greet
greet = Greeting(
    content="Welcome to couchdbkit world",

# save it


You can just use the db object to save a Schema: .

Your document greet is now in the greetings db. Each document is saved with a doc_type field that allow you to find easily each kind of document with the views. By default doc_type is the name of the class.

Now that you saved your document, you can update it: = u"Benoit Chesneau"

Here we updated the author name.

Dynamic properties

Mmm ok, but isn't CouchDB storing documents schema less? Do you want to add a property ? Easy:

greet.homepage = ""

Now you have just added an homepage property to the document.

Get all greetings

You first have to create a view and save it in the db. We will call it greeting/all. To do this we will use the loader system of couchdbkit that allows you to send views to CouchDB.

Let's create a folder that contains the design doc, and then the folder for the view. On unix:

mkdir -p ~/Work/couchdbkit/example/_design/greeting/views/all

In this folder we edit a file map.js:

function(doc) {
  if (doc.doc_type == "Greeting")
    emit(doc._id, doc);

Here is a folder structure:


---- greetings
------ view

Here is a screenshot:

A system will be provided to manage view creation and other things. As some noticed, this system works like couchapp and is fully compatible.

Then we use push function to send the design document to CouchDB:

from couchdbkit.designer import push
push('/path/to/example/_design/greetings', db)

The design doc is now in the greetings database and you can get all greets:

greets = Greeting.view('greeting/all')