-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathcouch.py
More file actions
27 lines (23 loc) · 703 Bytes
/
couch.py
File metadata and controls
27 lines (23 loc) · 703 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
from couchdbkit import Server
class Couch():
def __init__(self):
self.server = Server()
self.db = self.server.get_or_create_db('test')
if self.db.info()['doc_count'] > 0:
self.server.delete_db('test')
self.db = self.server.create_db('test')
def populate(self):
things = [
{"name": "Vishnu"},
{"name": "Lakshmi"},
{"name": "Ganesha"},
{"name": "Krishna"},
{"name": "Murugan"}
]
self.db.save_docs(things)
def count(self):
return self.db.all_docs().count()
if __name__ == "__main__":
couch = Couch()
couch.populate()
print(couch.count())