Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from neomodel import (config, StructuredNode, StringProperty, IntegerProperty,UniqueIdProperty, RelationshipTo, RelationshipFrom)
- config.DATABASE_URL = 'bolt://neo4j:anthrax1234@localhost:7687'
- class Country(StructuredNode):
- code = StringProperty(unique_index=True, required=True)
- # traverse incoming IS_FROM relation, inflate to Person objects
- inhabitant = RelationshipFrom('Person', 'IS_FROM')
- class Person(StructuredNode):
- uid = UniqueIdProperty()
- name = StringProperty(unique_index=True)
- age = IntegerProperty(index=True, default=0)
- # traverse outgoing IS_FROM relations, inflate to Country objects
- country = RelationshipTo(Country, 'IS_FROM')
- jim = Person(name='Jim', age=3).save()
- jim.age = 4
- jim.save() # validation happens here
- jim.delete()
- jim.refresh() # reload properties from neo
- jim.id # neo4j internal id
- ...
- File "/Users/sjamal/.conda/envs/tneo/lib/python3.6/site-
- packages/neomodel/core.py", line 452, in inflate
- if db_property in node.properties:
- AttributeError: 'Node' object has no attribute 'properties'
- File "/Users/sjamal/.conda/envs/tneo/lib/python3.6/ssl.py", line 817, in __init__
- self.do_handshake()
- File "/Users/sjamal/.conda/envs/tneo/lib/python3.6/ssl.py", line 1077, in do_handshake
- self._sslobj.do_handshake()
- File "/Users/sjamal/.conda/envs/tneo/lib/python3.6/ssl.py", line 689, in do_handshake
- self._sslobj.do_handshake()
- OSError: [Errno 0] Error
- from py2neo import Node, Relationship, Graph
- graph = Graph("localhost", user='neo4j', password='password', bolt=None)
- alice = Node("Person", name="Alice")
- bob = Node("Person", name="Bob")
- alice_knows_bob = Relationship(alice, "KNOWS", bob)
- File "/Users/sjamal/.conda/envs/py2neo_test/lib/python3.6/site-packages/neo4j/bolt/connection.py", line 459, in acquire
- connection = self.connector(address)
- File "/Users/sjamal/.conda/envs/py2neo_test/lib/python3.6/site-packages/neo4j/v1/bolt.py", line 46, in <lambda>
- pool = ConnectionPool(lambda a: connect(a, security_plan.ssl_context, **config))
- File "/Users/sjamal/.conda/envs/py2neo_test/lib/python3.6/site-packages/neo4j/bolt/connection.py", line 601, in connect
- raise ProtocolError("Connection to %r closed without handshake response" % (address,))
- neo4j.bolt.connection.ProtocolError: Connection to ('localhost', 7687) closed without handshake response
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement