Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

neomodel giving Attribute error on save

I am running the following config for neo4j:

neo4j - 3.0.0
py2neo - 2.0.8
neomodel - 2.0.2

Finally, the code I try to run is:

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()

I don't understand, why I keep getting this strange error. Am I doing something wrong here or should I use py2neo instead of neomodel?

My traceback is:

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'
like image 494
Sourabh Dev Avatar asked May 18 '16 11:05

Sourabh Dev


People also ask

Is it possible to create an abstract node class using neomodel?

This makes it possible to create a node class which extends the functionality that neomodel provides (such as neomodel.contrib.SemiStructuredNode ). Creating purely abstract classes is achieved using the __abstract_node__ property on base classes:

How does neomodel work internally?

neomodel internally creates a new session and through that session creates any additional transactions if required. neomodel internally creates and updates a node-class registry. Any additional threads spun up from this process will re-use the node-class registry.

Why is my model not working after saving?

Based on the error message it looks like you’ve used the former approach. If so, you would need to restore the file structures in your current working directly as they have been while saving the model.


1 Answers

Two points here:

  1. Existing Neomodel doesn't support the Neo4j 3.0

  2. Cypher syntax has changed in 3.0, so the error raises.

In 2.x , MATCH n RETURN n
In 3.0 , MATCH (n) RETURN n

Node n is enclosed in braces.

like image 66
Jack Daniel Avatar answered Sep 27 '22 18:09

Jack Daniel