Coder Social home page Coder Social logo

couchquery's Introduction

Couchquery

Build Status Coverage Status

Python library for simple and dynamic access to CouchDB. This libary is authored by Mikeal Rogers and currently maintained by Nicholas Tan Jerome.

Further document on this library can be obtained hier

Getting Started

You will need CouchDB

After installing CouchDB, start it with

sudo couchdb -b

You can now launch http://127.0.0.1:5984/_utils/index.html

Shutdown using

sudo couchdb -d

Installation

pip install couchquery

How to use

Couchquery is meant to be a simple python libary for CouchDB

Create a Database object for any CouchDB database you would like to interact with.

>>> db = Database('http://localhost:5984/buckaroo')

Create a new document in the database.

>>> db.create({'type':'red-lectroid','name':'John Whorfin'})
{u'rev': u'1-4198154595', u'ok': True, u'id': u'c581bbc8fd32f49ecb2f8668ed71fe9b'}

After creating a new document you are given the response dict from couch which includes the id of the document. You can also get documents by id.

>>> info = db.create({'type':'red-lectroid','name':'John Whorfin'})
>>> doc = db.get(info['id'])
>>> type(doc)
<class 'couchquery.Document'>

Document objects are just slightly extended dict objects that provide slightly simpler attribute access.

>>> doc.name
"John Worfin"
>>> doc['name']
"John Worfin"
>>> doc.location = "The 8th Dimension"
>>> doc.has_key('location')
True
>>> doc.get('fakeattribute', False)
False

When saving documents you must have the latest revision.

>>> db.update(doc)

Please read on the document for further information.

Changes

0.10.3

  • feature: added filters (beta)

0.10.2

  • feature: added compaction method

0.10.1

  • Hotfix: should not raise exception when it returns Http response 304.

0.10.0

  • https support
  • supports credentials usage
  • support url encoding on document id
  • better error message for createdb and deletedb

Tests

If you clone this repository, it is a good practice to run the tests first to make sure that you have a working environment. You can do this by either:

py.test tests

or

nosetests

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.