py2neo Graph.find_one()弃用警告?

时间:2017-03-12 00:08:00

标签: python neo4j py2neo

我在python 3.5上安装了py2neo 3.1.2版,当我运行以下代码时,我收到一个关于Graph.find_one的弃用警告,并告诉我使用NodeSelector。 v3 Documentation并未提及此折旧。当我在下面的代码中使用NodeSelector方法时,我最终得到了许多链接到单个事件节点的重复日历节点。如何更新代码以防止出现此警告?

我的图表上已有许多日历节点。我想让它通过这个字典并将它们附加到图表并将它们与相应的日历节点相关联。

for k,v in calendar_dict.items():
    calendar = graph.find_one("Calendar", property_key='url', property_value=v[2])
    calendar_event = Node("CalendarEvent", event=k, date=str(v[0]))
    graph.create(calendar_event)
    calendar_rel = Relationship(calendar_event, "POSTED_ON", calendar, 
                                scrape_date=str(datetime.date.today()))
    graph.create(calendar_rel)

警告

/home/mcamp/anaconda3/envs/py3.5/lib/python3.5/site-packages/ipykernel/__main__.py:2: DeprecationWarning: Graph.find_one is deprecated, use NodeSelector instead
  from ipykernel import kernelapp as app

1 个答案:

答案 0 :(得分:1)

不推荐使用find_one,并在source

中注明

要解决您的问题,请使用NodeSelector等效函数NodeSelection.first