python & couchdb sample

Lacking any good examples of how to use python’s couchdb module, I’ve managed to make pretty impressive progress (for me) on a 4th of July holiday.

I’ll try to recreated it here for others although I know it’ll be incomplete.

Consider it a syntactical example;

import couchdb
s = couchdb.Server(‘http://localhost:5984/’) ##why can’t it default to this?
db = s[‘stock_values’]
ids = []
stock_values = {}
for doc in db:

d = db[doc]
stock_values[d[‘symbol’]] = d[‘historical_data’]

More good examples are in the code;

About jay

I'm trying to build something interactive where I can learn from others and hopefully share useful knowledge too.
This entry was posted in code, couchdb, python. Bookmark the permalink.

4 Responses to python & couchdb sample

  1. jay says:

    Here’s how to create a named document instead of using db.create()

    db[“foo”] = { ‘something’ : “else”, ‘ok’: “works”}

  2. Pingback: thecapacity : What if stocks were movies?

  3. jay says:

    Silly Chris,
    couchdb is for geeks!

    Picture simplicity as an evolutionary trait and apply it to databases.
    We’re not yet sure if it’ll yield a failed branch of a full trunk but it’s a great exploration!

  4. chris says:

    why do you need a database for your couches? do you really have that many to keep track of?

Comments are closed.