Created
September 19, 2012 00:50
-
-
Save alex-ethier/3746989 to your computer and use it in GitHub Desktop.
couchbase perf tests
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 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() |
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
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() |
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 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