def format_list(self): db = Database('tucker') response = yield db.list('agenda/html', 'nomfup', key='n', limit=3, descending=True) print response.body
def why_init(self): db = Database('players') application = tornado.web.Application([ (r'/(.*?)/score)', RankingsUpdater), ]).listen(1920) tornado.ioloop.IOLoop.instance().start()
def why_jumpy(self): db = Database('players') class RankingsUpdater(tornado.web.RequestHandler): @tornado.web.asynchronous def post(self, player_id): self.new_score = int(self.request.body) db.get(player_id, callback=self.got_player) def got_player(doc, status): doc.score = self.new_score db.save(doc, callback=self.saved_player) def saved_player(conflicts, status): db.view('leaderboard/highscores', callback=self.got_highscores) def got_highscores(rows, status): self.write(json.dumps(rows)) self.finish()
def format_show(self): db = Database('mannion') response = yield db.show('records/csv', '1978-wotw', include_titles=True) print response.headers['Content-Type']
def query_simple(self): db = Database('dosac') rows = yield db.view('employees/byname') print rows
def batch_get(self): db = Database('backbench') doc_ids = ['ballentine', 'holhurst', 'swain'] docs = yield db.get(doc_ids) print docs[0]
def doc_get(self): db = Database('underlings') ollie = yield db.get('lackey-129') print ollie print 'Mr. %(first)s %(last)s can be found at %(office)s.' % ollie
def replicator_convenience(self): local_db = Database('localdb') yield local_db.push(remote_db, "http://elsewhere.com:5984/remotedb", continuous=True, _id='local-to-remote')
def changes_seq(self): db = Database('watched') info = yield db.info() print info.update_seq
def replicate_push(self): local_db = Database('localdb') remote_db = Database('http://elsewhere.com:5984/remotedb') yield local_db.push(remote_db) yield local_db.pull(remote_db)
def cords_boilerplate(self): from corduroy import Database, NotFound, relax people_db = Database('people') # i.e., http://127.0.0.1:5984/people
def db_init(self): db = Database('http://127.0.0.1:5984/some_db_name') db = Database('some_db_name')