Skip to content

Instantly share code, notes, and snippets.

@alex-ethier
Created September 19, 2012 00:50
Show Gist options
  • Save alex-ethier/3746989 to your computer and use it in GitHub Desktop.
Save alex-ethier/3746989 to your computer and use it in GitHub Desktop.
couchbase perf tests
from couchbase.client import Couchbase
def insert_doc():
couchbase = Couchbase("localhost:8091", "account", "")
bucket = couchbase["account"]
key = "test_key"
val = "test_val"
bucket.set(key, 0, 0, val)
insert_doc()
import httplib2
import json
def insert_doc():
http = httplib2.Http()
http.add_credentials("Administrator", "password")
doc_name = "mydoc"
url = 'http://127.0.0.1:8092/account/%s' % doc_name
doc = {"doc_foo": "foo", "doc_bar": "bar"}
body = json.dumps(doc, sort_keys=True, indent=4)
response, content = http.request(
url,
'PUT',
body,
headers={'Content-type': 'application/json'}
)
insert_doc()
from couchbase.client import Couchbase
def get_doc():
couchbase = Couchbase("localhost:8091", "account", "")
bucket = couchbase["account"]
bucket.get("test_key")
get_doc()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment