0

我对 CouchDB 很陌生,在尝试更新文档时遇到冲突错误。

>>> cachefile_db["ABC"] = {1:1}
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/site-packages/couchdb/client.py", line 344, in __setitem__
    status, headers, data = resource.put_json(body=content)
  File "/usr/local/lib/python2.7/site-packages/couchdb/http.py", line 531, in put_json
    **params)
  File "/usr/local/lib/python2.7/site-packages/couchdb/http.py", line 546, in _request_json
    headers=headers, **params)
  File "/usr/local/lib/python2.7/site-packages/couchdb/http.py", line 542, in _request
    credentials=self.credentials)
  File "/usr/local/lib/python2.7/site-packages/couchdb/http.py", line 394, in request
    raise ResourceConflict(error)
couchdb.http.ResourceConflict: (u'conflict', u'Document update conflict.')

我可以删除记录然后读取它,避免冲突错误的建议/最佳方法是什么?

谢谢,

4

1 回答 1

2

出现冲突是因为您的文档中没有 _rev。我建议先从数据库加载文档(使用_rev),然后修改它并保存回来。

于 2013-11-04T17:02:04.180 回答