Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Python utilities to make CouchDB more pleasant. [Not actively maintained]

Notifications You must be signed in to change notification settings

tammyd/couchdb-python-utils

Open more actions menu
 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 

Repository files navigation

couchdb-python-utils/doc_utils.py

This script facilitates validating JSON and Python datastructures, and then POST or PUTing them to a CouchDB server.

This is tested for the 0.8x branch, but not 0.9x. It seems there are some small breaking changes (or perhaps just bugs ;) in 0.9, so the script may require some minor modifications before using it there.

Usage

This script facilitates validating JSON and Python datastructures, and then POST or PUTing them to a CouchDB server.

The script has one required and one or more optional positional parameters:

python doc_utils database-name
python doc_utils database-name path/to/folder/or/file
python doc_utils database-name doc1.py doc2.py doc3.json doc4.js

If you specify a folder, then the script will examine all .py, .json, and .js files in the folder, and--if they meet the format requirements--send them to CouchDB.

Invoke help at the command-line for more options

python doc_utils --help

Format for Individual Documents

For format for a .py file a dictionary.

{
    '_id': '123123',
    'title': "hi"
}

The format for .js and .json files is a JS dictionary.

{
    "_id":"101",
    "desc":"and a description"
}

In general the distinction between the two will typically be quite small, but remember that JSON technically doesn't permit a comma after the last element in an array/dictionary.

  • Individual documents are always PUT.
  • Thus they must have an ID specified.
  • They will not overwrite existing documents with the same ID.

Format for Bulk Documents

The format for bulk documents is identical to that of individual documents, but they must be a list/array instead of a dict.

Python looks like:

[
    {'_id': '123123','title': "hi"},
    {'title': "goodbye"}
]

Actually, thats exactly what the JSON version will look like as well. Cool, eh?

  • Bulk documents are always POSTed, and thus do not require IDs (but may have them).
  • This will overwrite existing documents with the same IDs.

About

Python utilities to make CouchDB more pleasant. [Not actively maintained]

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%
Morty Proxy This is a proxified and sanitized view of the page, visit original site.