Skip to content

Instantly share code, notes, and snippets.

@abhi-bit
Created September 24, 2015 08:24
Show Gist options
  • Save abhi-bit/a2d975e316ed7178f14f to your computer and use it in GitHub Desktop.
Save abhi-bit/a2d975e316ed7178f14f to your computer and use it in GitHub Desktop.
set to cb using file from disk
import sys
import json
import random
import string
from couchbase import Couchbase
from couchbase import FMT_JSON
host = sys.argv[1]
bucket = sys.argv[2]
file_to_read = sys.argv[3]
key_name_size = 10
cb = Couchbase.connect(host=host, bucket=bucket)
with open(file_to_read) as json_file:
json_data = json.load(json_file)
key = ''.join(random.choice(string.ascii_uppercase + string.digits) for _ in range(key_name_size))
print "Setting key %s" % key
cb.set(key ,json_data, format=FMT_JSON)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment