您好我想更新一些匹配查询的文档。'parent_id'
因此,对于每个文档,当且仅当此文档具有 IDgreater then
即 6时,我才想更新该字段
for result in results:
db.update(set('parent_id', current_element_id),
result.get('id') > current_element_id )
错误:
Traceback (most recent call last):
File "debug.py", line 569, in <module>
convertxml=parse(xmlfile, force_list=('interface',))
File "debug.py", line 537, in parse
parser.Parse(xml_input, True)
File "..\Modules\pyexpat.c", line 468, in EndElement
File "debug.py", line 411, in endElement
db.update(set('parent_id', current_element_id), result.get('id') > current_element_id )
File "C:\ProgramData\Miniconda3\lib\site-packages\tinydb\database.py", line 477, in update
cond, doc_ids
File "C:\ProgramData\Miniconda3\lib\site-packages\tinydb\database.py", line 319, in process_elements
if cond(data[doc_id]):
TypeError: 'bool' object is not callable
应该更新的文档示例:
...,
{'URI': 'http://www.john-doe/',
'abbr': 'IDD',
'affiliation': 'USA',
'closed': False,
'created': '2018-06-01 22:49:02.927347',
'element': 'distrbtr',
'id': 7,
'parent_id': None
},...
在tinydb的文档中,我看到我可以使用set。否则,如果我不使用Set,它将更新所有我不想更新的文档。db.update(dict)