本文整理汇总了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
示例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: