当前位置: 首页>>代码示例>>Python>>正文


Python Cloudant.all_dbs方法代码示例

本文整理汇总了Python中cloudant.account.Cloudant.all_dbs方法的典型用法代码示例。如果您正苦于以下问题:Python Cloudant.all_dbs方法的具体用法?Python Cloudant.all_dbs怎么用?Python Cloudant.all_dbs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cloudant.account.Cloudant的用法示例。


在下文中一共展示了Cloudant.all_dbs方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: setup_db

# 需要导入模块: from cloudant.account import Cloudant [as 别名]
# 或者: from cloudant.account.Cloudant import all_dbs [as 别名]
def setup_db(username, password, url):
	
	dbname = "spark_data"

	client = Cloudant(username, password, url=url)

	client.connect()

	# Perform client tasks...
	session = client.session()
	print 'Username: {0}'.format(session['userCtx']['name'])
	databases = client.all_dbs()
	
	db = client.create_database(dbname)

	print 'Databases: {0}'.format(client.all_dbs())

	return db
开发者ID:benCoomes,项目名称:projectSol,代码行数:20,代码来源:sparkclient.py

示例2: RuntimeError

# 需要导入模块: from cloudant.account import Cloudant [as 别名]
# 或者: from cloudant.account.Cloudant import all_dbs [as 别名]
if 'credentials' not in TONE:
    raise RuntimeError("Cannot connect to Watson.  Credentials not found for personality insights.")
else:
    tone_analyzer = ToneAnalyzerV3Beta(username=TONE['credentials']['username'], password=TONE['credentials']['password'], version='2016-02-11')
    

CLOUDANT = json.loads(os.environ['VCAP_SERVICES'])['cloudantNoSQLDB'][0]
if 'credentials' not in CLOUDANT:
    raise RuntimeError("Cannot connect to database, Cloudant credentials not found.")
else:
    client = Cloudant(CLOUDANT['credentials']['username'], CLOUDANT['credentials']['password'], url=CLOUDANT['credentials']['url'])
    client.connect()

databases = ['personas', 'albums', 'songs']
for db in databases:
    if db not in client.all_dbs():
        raise RuntimeError("Database " + db + " not found, please ensure you have the needed data.")

cached_tone = {}
for persona in client['personas']:
    cached_tone[persona['_id']] = None

cached_persona_insights = {}
for persona in client['personas']:
    cached_persona_insights[persona['_id']] = None

def assemble_persona_text(persona):
    text = ''
    for album in client['personas'][persona]['albums']:
        for song in client['albums'][album['title']]['songs']:            
            try:
开发者ID:IBM-Bluemix,项目名称:ziggy,代码行数:33,代码来源:server.py


注:本文中的cloudant.account.Cloudant.all_dbs方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。