【问题标题】:How do I make a query in cloudant-python selecting an specific field?如何在 cloudant-python 中选择特定字段进行查询?
【发布时间】:2020-02-03 06:31:10
【问题描述】:

我正在尝试进行仅选择其中一个字段/属性的查询。查询应该产生类似 nameField 或 numberField 的数组,甚至是单个变量,我想要的是分隔值以便我可以在应用程序中对其进行操作

我已经尝试过使用"query = cloudant.query.Query(myDatabaseDemo, fields=['nameField'])",但是打印查询时的结果只是"fields=['nameField']"。

from cloudant.result import Result, ResultByKey

...

client = Cloudant(serviceUsername, servicePassword, url=serviceURL)
myDatabaseDemo = client.create_database(databaseName)

...

result_collection = Result(myDatabaseDemo.all_docs, include_docs=True)
print ("document:\n{0}\n".format(result_collection[0]))

实际代码产生一组值,就像一个json文档

【问题讨论】:

    标签: python cloudant python-cloudant


    【解决方案1】:

    您是否尝试过使用Cloudant query?它允许您指定fields (list) – A list of fields to be returned by the query.

    【讨论】:

      猜你喜欢
      • 2015-07-24
      • 1970-01-01
      • 1970-01-01
      • 2020-10-17
      • 2013-08-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多