5

我正在为 neo4j 运行以下配置:

neo4j - 3.0.0
py2neo - 2.0.8
neomodel - 2.0.2

最后,我尝试运行的代码是:

class User(neomodel.StructuredNode):
    user_id = neomodel.IntegerProperty(unique_index=True, required=True)
    name = neomodel.StringProperty()
    phone_number = neomodel.StringProperty()

user = User(user_id=6, name='Sourabh Dev', phone_number='9711237840').save()

我不明白,为什么我不断收到这个奇怪的错误。我在这里做错了什么还是应该使用py2neo而不是neomodel?

我的回溯是:

Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "/usr/local/lib/python3.4/site-packages/neomodel-2.0.2-py3.4.egg/neomodel/signals.py", line 25, in hooked
    val = fn(self, *args, **kwargs)
  File "/usr/local/lib/python3.4/site-packages/neomodel-2.0.2-py3.4.egg/neomodel/core.py", line 159, in save
    self._id = self.create(self.__properties__)[0]._id
  File "/usr/local/lib/python3.4/site-packages/neomodel-2.0.2-py3.4.egg/neomodel/core.py", line 289, in create
    results = db.cypher_query(query, params)
  File "/usr/local/lib/python3.4/site-packages/neomodel-2.0.2-py3.4.egg/neomodel/util.py", line 213, in cypher_query
    results = self._execute_query(query, params)
  File "/usr/local/lib/python3.4/site-packages/neomodel-2.0.2-py3.4.egg/neomodel/util.py", line 207, in _execute_query
    results = self.session.cypher.execute(query, create_params=params)
  File "/usr/local/lib/python3.4/site-packages/py2neo/cypher/core.py", line 136, in execute
    results = tx.commit()
  File "/usr/local/lib/python3.4/site-packages/py2neo/cypher/core.py", line 333, in commit
    return self.post(self.__commit or self.__begin_commit)
  File "/usr/local/lib/python3.4/site-packages/py2neo/cypher/core.py", line 288, in post
    raise self.error_class.hydrate(error)
  File "/usr/local/lib/python3.4/site-packages/py2neo/cypher/error/core.py", line 54, in hydrate
    error_cls = getattr(error_module, title)
AttributeError: 'module' object has no attribute 'TypeError'
4

1 回答 1

5

这里有两点:

  1. 现有的 Neomodel 不支持 Neo4j 3.0

  2. Cypher 语法在 3.0 中已更改,因此会出现错误。

在 2.x 中,匹配n返回 n
在 3.0 中,匹配(n)返回 n

节点 n 用大括号括起来。

于 2016-05-19T06:15:33.267 回答