Example #1
0
 def setup(self, graph):
     self.graph = graph
     try:
         self.graph.legacy.delete_index(Node, "People")
     except LookupError:
         pass
     self.store = Store(self.graph)
 def __init__(self, host, port, username, password):
     #Authenticate and Connect to the Neo4j Graph Database
     py2neo.authenticate(host + ':' + port, username, password)
     graph = Graph('http://' + host + ':' + port + '/db/data/')
     store = Store(graph)
     #Store the reference of Graph and Store.
     self.graph = graph
     self.store = store
Example #3
0
    def test_can_execute_example_code(self):
        class Person(object):
            def __init__(self, email=None, name=None, age=None):
                self.email = email
                self.name = name
                self.age = age

            def __str__(self):
                return self.name

        graph = Graph()
        store = Store(graph)

        alice = Person("*****@*****.**", "Alice", 34)
        store.save_unique("People", "email", alice.email, alice)

        bob = Person("*****@*****.**", "Bob", 66)
        carol = Person("*****@*****.**", "Carol", 42)
        store.relate(alice, "LIKES", bob)
        store.relate(alice, "LIKES", carol)
        store.save(alice)

        friends = store.load_related(alice, "LIKES", Person)
        print("Alice likes {0}".format(" and ".join(str(f) for f in friends)))
Example #4
0
 def setup(self, graph):
     self.graph = graph
     self.store = Store(self.graph)
Example #5
0
 def __init__(self, host, port, username, password):
     py2neo.authenticate(host + ':' + port, username, password)
     graph = Graph('http://' + host + ':' + port + '/db/data/')
     store = Store(graph)
     self.graph = graph
     self.store = store