我一直在尝试从Cloudant中的文档中获取附件图像数据。一旦选择了一个文档(用_id直接提取,等等),我就可以成功地完成。
现在尝试使用选择器结合"query“操作,我遇到了麻烦。
这是我的代码。
targetName="chibika33"
targetfile="chibitest.png"
#--------------------------------------------------
# get all the documents with the specific nameField
#--------------------------------------------------
myDatabase.create_query_index(fields = ['nameField'])
selector = {'nameField': {'$eq': targetName}}
docs = myDatabase.get_query_result(selector)
#--------------------------------------------------
# get the attachment files to them, save it locally
#--------------------------------------------------
count = 0
for doc in docs:
count=count+1
result_filename="result%03d.png"%(count)
dataContent = doc.get_attachment(targetfile, attachment_type='binary')
dataContentb =base64.b64decode(dataContent)
with open(result_filename,'wb') as output:
output.write(dataContentb)导致错误为;
Traceback (most recent call last):
File "view8.py", line 44, in <module>
dataContent = doc.get_attachment(targetfile, attachment_type='binary')
AttributeError: 'dict' object has no attribute 'get_attachment'到目前为止,我在python-cloudant- document ...python-cloudant document:http://python-cloudant.readthedocs.io/en/latest/index.html中找不到任何将dict转换为document对象的API
任何建议都将不胜感激。
https://stackoverflow.com/questions/47665798
复制相似问题