-
-
Save lukecampbell/1712735 to your computer and use it in GitHub Desktop.
A small script to do couchdb operations in coi-services.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pyon.datastore.couchdb.couchdb_datastore import CouchDB_DataStore | |
from interface.objects import BlogPost, BlogAuthor, BlogComment | |
from pyon.core.exception import BadRequest | |
import time | |
db = CouchDB_DataStore() | |
# Creates a datastore | |
datastore_name = 'dm_datastore' | |
try: | |
db.create_datastore(datastore_name) | |
except BadRequest: | |
print 'Already exists' | |
# Create a document | |
author = BlogAuthor(name='Luke Campbell',email='[email protected]') | |
content = """ | |
So this is the story of my life. | |
There I was... | |
The end. | |
""" | |
post = BlogPost(title='my posts is here', author=author,content=content,updated=time.ctime()) | |
_id, _rev = db.create(post, None, datastore_name) | |
content = """ | |
Hey Luke nice post! | |
""" | |
comment = BlogComment(author=author,content=content,ref_id = _id) | |
_id, _rev = db.create(comment, None, datastore_name) | |
content = """ | |
This is my second blog post today! | |
""" | |
post = BlogPost(title='my posts is here', author=author,content=content,updated=time.ctime()) | |
_id, _rev = db.create(post, None, datastore_name) | |
content = """ | |
It's the end of the world as we know it. | |
And I feel fine. | |
""" | |
post = BlogPost(title='my posts is here', author=author,content=content,updated=time.ctime()) | |
_id, _rev = db.create(post, None, datastore_name) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment