Created
September 24, 2015 08:24
-
-
Save abhi-bit/a2d975e316ed7178f14f to your computer and use it in GitHub Desktop.
set to cb using file from disk
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 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