Advertisement
Guest User

Untitled

a guest
Mar 2nd, 2019
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.09 KB | None | 0 0
  1. from neomodel import (config, StructuredNode, StringProperty, IntegerProperty,UniqueIdProperty, RelationshipTo, RelationshipFrom)
  2.  
  3. config.DATABASE_URL = 'bolt://neo4j:anthrax1234@localhost:7687'
  4.  
  5. class Country(StructuredNode):
  6. code = StringProperty(unique_index=True, required=True)
  7.  
  8. # traverse incoming IS_FROM relation, inflate to Person objects
  9. inhabitant = RelationshipFrom('Person', 'IS_FROM')
  10.  
  11.  
  12. class Person(StructuredNode):
  13. uid = UniqueIdProperty()
  14. name = StringProperty(unique_index=True)
  15. age = IntegerProperty(index=True, default=0)
  16.  
  17. # traverse outgoing IS_FROM relations, inflate to Country objects
  18. country = RelationshipTo(Country, 'IS_FROM')
  19.  
  20. jim = Person(name='Jim', age=3).save()
  21. jim.age = 4
  22. jim.save() # validation happens here
  23. jim.delete()
  24. jim.refresh() # reload properties from neo
  25. jim.id # neo4j internal id
  26.  
  27. ...
  28. File "/Users/sjamal/.conda/envs/tneo/lib/python3.6/site-
  29. packages/neomodel/core.py", line 452, in inflate
  30. if db_property in node.properties:
  31. AttributeError: 'Node' object has no attribute 'properties'
  32.  
  33. File "/Users/sjamal/.conda/envs/tneo/lib/python3.6/ssl.py", line 817, in __init__
  34. self.do_handshake()
  35. File "/Users/sjamal/.conda/envs/tneo/lib/python3.6/ssl.py", line 1077, in do_handshake
  36. self._sslobj.do_handshake()
  37. File "/Users/sjamal/.conda/envs/tneo/lib/python3.6/ssl.py", line 689, in do_handshake
  38. self._sslobj.do_handshake()
  39. OSError: [Errno 0] Error
  40.  
  41. from py2neo import Node, Relationship, Graph
  42.  
  43. graph = Graph("localhost", user='neo4j', password='password', bolt=None)
  44.  
  45. alice = Node("Person", name="Alice")
  46. bob = Node("Person", name="Bob")
  47. alice_knows_bob = Relationship(alice, "KNOWS", bob)
  48.  
  49. File "/Users/sjamal/.conda/envs/py2neo_test/lib/python3.6/site-packages/neo4j/bolt/connection.py", line 459, in acquire
  50. connection = self.connector(address)
  51. File "/Users/sjamal/.conda/envs/py2neo_test/lib/python3.6/site-packages/neo4j/v1/bolt.py", line 46, in <lambda>
  52. pool = ConnectionPool(lambda a: connect(a, security_plan.ssl_context, **config))
  53. File "/Users/sjamal/.conda/envs/py2neo_test/lib/python3.6/site-packages/neo4j/bolt/connection.py", line 601, in connect
  54. raise ProtocolError("Connection to %r closed without handshake response" % (address,))
  55. neo4j.bolt.connection.ProtocolError: Connection to ('localhost', 7687) closed without handshake response
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement