Integrating neo4j With Python

That is very easy :P  

On a windows environment.

1-> Download neo4j  then Next  next next ..  Done  with the DB .. 

2-> Download python runtime. 3 or 2 either series would work.  then next , next , next ..Done with the  Python.

Note : there are many community developed drivers, But for me, below version working perfectly  for years   :D 


Install neo4j library :

pip install neo4j


Sample snippet:


from neo4j import GraphDatabase class HelloWorldExample: def __init__(self, uri, user, password): self.driver = GraphDatabase.driver(uri, auth=(user, password)) def close(self): self.driver.close() def print_greeting(self, message): with self.driver.session() as session: greeting = session.write_transaction(self._create_and_return_greeting, message) print(greeting) @staticmethod def _create_and_return_greeting(tx, message): result = tx.run("CREATE (a:Greeting) " "SET a.message = $message " "RETURN a.message + ', from node ' + id(a)", message=message) return result.single()[0] if __name__ == "__main__": greeter = HelloWorldExample("bolt://localhost:7687", "neo4j", "password") greeter.print_greeting("hello, world") greeter.close()


Now you can play with your Cypher ...

No comments:

Post a Comment

Project Orion Nuclear Pulse Rocket

   refs: https://www.ans.org/news/article-1294/nuclear-pulse-propulsion-gateway-to-the-stars/ https://ntrs.nasa.gov/api/citations/2000009650...