neomodel 在保存时给出属性错误
neomodel giving Attribute error on save
我正在运行为 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'
这里有两点:
现有的 Neomodel 不支持 Neo4j 3.0
Cypher 语法在 3.0 中发生了变化,因此出现错误。
在 2.x 中,匹配 n RETURN n
在 3.0 中,匹配 (n) RETURN n
节点 n 用大括号括起来。
我正在运行为 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'
这里有两点:
现有的 Neomodel 不支持 Neo4j 3.0
Cypher 语法在 3.0 中发生了变化,因此出现错误。
在 2.x 中,匹配 n RETURN n
在 3.0 中,匹配 (n) RETURN n
节点 n 用大括号括起来。