Skip to main content

About the jsonobject fork of couchdbkit

jsonobject-couchdbkit is a fork of couchdbkit that replaces couchdbkit.schema with a thin wrapper around jsonobject (which was, incidentally, written as a way faster replacement for couchdbkit.schema.) See jsonobject.

About

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

Installation

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 http://python-distribute.org/distribute_setup.py
$ sudo python distribute_setup.py
$ 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"}
db.save_doc(doc)
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
Greeting.set_db(db)

# create a new greet
greet = Greeting(
    author="Benoit",
    content="Welcome to couchdbkit world",
    date=datetime.datetime.utcnow()
)

# save it
greet.save()

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:

greet.author = u"Benoit Chesneau"
greet.save()

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 = "http://www.e-engura.org"
greet.save()

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:

/Work/couchdbkit/example/:

--_design/
---- greetings
------ view

Here is a screenshot:

http://couchdbkit.org/images/gettingstarted.png

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')

Release files for jsonobject-couchdbkit 1.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for jsonobject-couchdbkit 1.1.0
File Size Uploaded
jsonobject-couchdbkit-1.1.0.tar.gz 66.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for jsonobject-couchdbkit 1.1.0
File Interpreter ABI Platform
jsonobject_couchdbkit-1.1.0-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 123.1 kB

Release files / jsonobject-couchdbkit-1.1.0.tar.gz

Download URL jsonobject-couchdbkit-1.1.0.tar.gz
Size 66.4 kB
Tags Source
SHA-256 checksum
How to use checksums
11d661140889df193b2c7070b44c0376498ee39b0a5fbde847a610a252368071
BLAKE2b-256 checksum
How to use checksums
1a778e727c13d4e38c932c05be1784d48ec8c558d47f88a3786b3b3e73edf2c1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.18

Release files / jsonobject_couchdbkit-1.1.0-py2.py3-none-any.whl

Download URL jsonobject_couchdbkit-1.1.0-py2.py3-none-any.whl
Size 56.7 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
7c437d44d6a535ae6be83e30a5a7043677ecaf374cb89dc60139ee95de10877d
BLAKE2b-256 checksum
How to use checksums
812cdd1a66f829ceeae16db409352f24daa2e2817d7867a0b643819a4a116edb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.18

Release history Release notifications | RSS feed

This release

1.1.0 This release

2 release files

1.0.1

2 release files

0.9.16

1 release file

0.9.15

1 release file

0.9.12

2 release files

0.9.10

2 release files

0.9.9

1 release file

0.9.8.4

1 release file

0.9.8.3

1 release file

0.9.8.2

1 release file

0.9.8.1

1 release file

0.9.8

1 release file

0.9.7

1 release file

0.9.6

1 release file

0.9.5

1 release file

0.9.4

1 release file

0.9.3

1 release file

0.9.2

2 release files

0.9.1

1 release file

0.9.0.1

1 release file

0.9.0.0

1 release file

0.8.0.1

1 release file

0.8.0.0

1 release file

0.7.4.2

1 release file

0.7.4.0

1 release file

0.7.3.0

1 release file

0.7.2.0

1 release file

0.7.1.0

1 release file

0.7.0.1

1 release file

0.7.0.0

1 release file

0.6.5.7

1 release file

0.6.5.6

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page