本文整理汇总了Python中couchbase.cluster.Cluster.open_bucket方法的典型用法代码示例。如果您正苦于以下问题:Python Cluster.open_bucket方法的具体用法?Python Cluster.open_bucket怎么用?Python Cluster.open_bucket使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类couchbase.cluster.Cluster
的用法示例。
在下文中一共展示了Cluster.open_bucket方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_PYCBC_488
# 需要导入模块: from couchbase.cluster import Cluster [as 别名]
# 或者: from couchbase.cluster.Cluster import open_bucket [as 别名]
def test_PYCBC_488(self):
cluster = Cluster('couchbases://10.142.175.101?certpath=/Users/daschl/tmp/ks/chain.pem&keypath=/Users/daschl/tmp/ks/pkey.key')
with self.assertRaises(MixedAuthError) as maerr:
cluster.open_bucket("pixels",
password=self.cluster_info.bucket_password)
exception = maerr.exception
self.assertIsInstance(exception, MixedAuthError)
self.assertRegex(exception.message, r'.*CertAuthenticator.*password.*')
示例2: _createConn
# 需要导入模块: from couchbase.cluster import Cluster [as 别名]
# 或者: from couchbase.cluster.Cluster import open_bucket [as 别名]
def _createConn(self):
try:
cluster = Cluster(self.connection_string, bucket_class=CouchbaseBucket)
cluster.authenticate(PasswordAuthenticator(self.bucket, 'password'))
self.cb = cluster.open_bucket(self.bucket)
except BucketNotFoundError:
raise
except AuthError:
# Try using default user created by the tests, if any, in case there is no user with bucket name in the
# cluster.
try:
cluster = Cluster(self.connection_string, bucket_class=CouchbaseBucket)
cluster.authenticate(PasswordAuthenticator("cbadminbucket", 'password'))
self.cb = cluster.open_bucket(self.bucket)
except AuthError:
raise
示例3: create_xattr_data
# 需要导入模块: from couchbase.cluster import Cluster [as 别名]
# 或者: from couchbase.cluster.Cluster import open_bucket [as 别名]
def create_xattr_data(self, type="system"):
cluster = Cluster('couchbase://'+str(self.master.ip))
authenticator = PasswordAuthenticator(self.username, self.password)
cluster.authenticate(authenticator)
cb = cluster.open_bucket('default')
docs = self.get_meta_ids()
self.log.info("Docs: " + str(docs[0:5]))
xattr_data = []
self.log.info("Adding xattrs to data")
val = 0
for doc in docs:
if type == "system":
rv = cb.mutate_in(doc["id"], SD.upsert('_system1', val, xattr=True, create_parents=True))
xattr_data.append({'_system1': val})
rv = cb.mutate_in(doc["id"], SD.upsert('_system2', {'field1': val, 'field2': val*val}, xattr=True, create_parents=True))
xattr_data.append({'_system2': {'field1': val, 'field2': val*val}})
rv = cb.mutate_in(doc["id"], SD.upsert('_system3', {'field1': {'sub_field1a': val, 'sub_field1b': val*val}, 'field2': {'sub_field2a': 2*val, 'sub_field2b': 2*val*val}}, xattr=True, create_parents=True))
xattr_data.append({'_system3': {'field1': {'sub_field1a': val, 'sub_field1b': val*val}, 'field2': {'sub_field2a': 2*val, 'sub_field2b': 2*val*val}}})
if type == "user":
rv = cb.mutate_in(doc["id"], SD.upsert('user1', val, xattr=True, create_parents=True))
xattr_data.append({'user1': val})
rv = cb.mutate_in(doc["id"], SD.upsert('user2', {'field1': val, 'field2': val*val}, xattr=True, create_parents=True))
xattr_data.append({'user2': {'field1': val, 'field2': val*val}})
rv = cb.mutate_in(doc["id"], SD.upsert('user3', {'field1': {'sub_field1a': val, 'sub_field1b': val*val}, 'field2': {'sub_field2a': 2*val, 'sub_field2b': 2*val*val}}, xattr=True, create_parents=True))
xattr_data.append({'user3': {'field1': {'sub_field1a': val, 'sub_field1b': val*val}, 'field2': {'sub_field2a': 2*val, 'sub_field2b': 2*val*val}}})
val = val + 1
self.log.info("Completed adding " + type + "xattrs to data to " + str(val) + " docs")
return xattr_data
示例4: _createConn
# 需要导入模块: from couchbase.cluster import Cluster [as 别名]
# 或者: from couchbase.cluster.Cluster import open_bucket [as 别名]
def _createConn(self):
try:
cluster = Cluster(self.connection_string, bucket_class=CouchbaseBucket)
cluster.authenticate(PasswordAuthenticator(self.bucket, 'password'))
self.cb = cluster.open_bucket(self.bucket)
except BucketNotFoundError:
raise
示例5: test_PYCBC_489
# 需要导入模块: from couchbase.cluster import Cluster [as 别名]
# 或者: from couchbase.cluster.Cluster import open_bucket [as 别名]
def test_PYCBC_489(self):
from couchbase.cluster import Cluster
with self.assertRaises(MixedAuthError) as maerr:
cluster = Cluster('couchbases://10.142.175.101?certpath=/Users/daschl/tmp/ks/chain.pem&keypath=/Users/daschl/tmp/ks/pkey.key')
cb = cluster.open_bucket('pixels', password = 'foo')
cb.upsert('u:king_arthur', {'name': 'Arthur', 'email': '[email protected]', 'interests': ['Holy Grail', 'African Swallows']})
exception = maerr.exception
self.assertIsInstance(exception, MixedAuthError)
self.assertRegex(exception.message, r'.*CertAuthenticator-style.*password.*')
示例6: create_connections
# 需要导入模块: from couchbase.cluster import Cluster [as 别名]
# 或者: from couchbase.cluster.Cluster import open_bucket [as 别名]
def create_connections(self):
"""
Create bucket connections. 5 bucket connections are created per instance.
:return: Nothing
"""
for i in range(0, self.threads):
if self.cb_version > '5':
cluster = Cluster(self.spec)
auth = PasswordAuthenticator(self.user, self.password)
cluster.authenticate(auth)
bucket = cluster.open_bucket(self.bucket_name, lockmode=LOCKMODE_WAIT)
bucket.timeout = self.timeout
self.connections.append(bucket)
else:
bucket = Bucket('{0}/{1}'.format(self.spec, self.bucket_name), lockmode=LOCKMODE_WAIT)
bucket.timeout = self.timeout
self.connections.append(bucket)
示例7: _connect
# 需要导入模块: from couchbase.cluster import Cluster [as 别名]
# 或者: from couchbase.cluster.Cluster import open_bucket [as 别名]
def _connect(self):
"""Establish a connection to the Couchbase cluster."""
cluster = Cluster('http://{}:{}'.format(self.host, self.port))
authenticator = PasswordAuthenticator('Administrator', self.password)
cluster.authenticate(authenticator)
self.client = cluster.open_bucket(self.bucket)
示例8: tst
# 需要导入模块: from couchbase.cluster import Cluster [as 别名]
# 或者: from couchbase.cluster.Cluster import open_bucket [as 别名]
#!/usr/bin/env python
from couchbase.cluster import Cluster, PasswordAuthenticator
from couchbase.exceptions import NotFoundError
def tst(cb, key):
try:
cb.remove(key)
except NotFoundError:
print ('Nothing to delete')
rv = cb.upsert(key, {'hello': 'world'})
cas = rv.cas
print(rv)
item = cb.get(key)
print(item)
cluster = Cluster('couchbase://localhost:12000')
cluster.authenticate(PasswordAuthenticator('Administrator', 'asdasd'))
cb = cluster.open_bucket('test')
tst(cb, 'blah')