1

Sorry as a beginner I do not see how to display a graph directly from python. I can well create some graph in the DB and see them in the default http://localhost:7474/browser/ but not automatically.

from py2neo import Graph, Node, Relationship, Path
graph = Graph()
bob = Node("Person", name="Bob")
#.........
graph.create(bob, ......)
graph.cypher.execute("MATCH (p:Person) - [r] - (x) RETURN p, r, x")
# No result, I did need to type it again in the browser ?????  
graph.open_browser() # open the standard browser but empty
leppie
  • 115,091
  • 17
  • 196
  • 297
  • In what context would you like the graph to appear? On a web page? In a local workstation window? On television? ... – wallyk Apr 20 '15 at 08:34

1 Answers1

1

Py2neo is a client library to interact with a neo4j server from Python. It does not show you a graph in the neo4j webinterface.

If you want to open a browser from Python, try the webbrowser module:

import webbbrowser

url = 'http://localhost:7474'

webbrowser.open(url, new=2) # new=2 opens a new tab

But as far as I know it's not possible to pass a Cypher query to the webinterface with a parameter.

What do you want to do with the results of your query?

Update

For the Python web application backend you should have a look at the Flask framework: http://flask.pocoo.org. With Flask it's very easy to create endpoints for your graph interactions (e.g. get more data on click or perform some graph operation).

If you want an interactive graph visualization in the frontend, try e.g. cytoscape.js (http://js.cytoscape.org) and see this question.

The neo4j web interface is not meant to be used as by end users of your application.

Community
  • 1
  • 1
Martin Preusse
  • 9,151
  • 12
  • 48
  • 80
  • More about the context of my question. I want to make a prototype of patient record in a medical collaborative network. The goal is to take advantage of graph technologies in order to provide a synthesis of the situation, as a graph showing the relations between symptoms, medical problems, actions and related medical knowledge. – Etienne Saliez Apr 19 '15 at 18:53