Database Reference
In-Depth Information
Querying with a Label
To get nodes that use a specific la bel, use the function called getNodes. This function returns value is a result Row
object, which can be iterated over like an array (Listing 9-11).
Listing 9-11. Querying with a Label
from py2neo import neo4j, ogm, node, rel
# set connection information (defaults to: http://localhost:7474/db/data/)
graph_db = neo4j.GraphDatabaseService()
# property_key and property_value default to None
users = list(graph_db.find('User', property_key='name', property_value='Brad'))
Developing a Python and Neo4j Application
Preliminary to building out your first Python and Neo4j application, this section covers the basics of configuring a
development environment.
Again, if you have not worked through the installation steps in Chapter 2, please take a few minutes to install it.
Preparing the Graph
In order to spend more time highlighting code examples for each of the more common graph models, you will use a
preloaded instance of Neo4j including necessary plugins, such as the spatial plugin.
To quickly set up a server instance with the sample data and plugins for this chapter, go to graphstory.com/
practicalneo4j . You will be provided with your own free trial instance, a knowledge base, and email support from Graph
Story. Alternatively, you may run a local Neo4j database instance with the sample data by going to graphstory.com/
practicalneo4j , downloading the zip file containing the sample database and plugins, and adding them to your local
instance.
Tip
Using the Sample Application
If you have already downloaded the sample application from graphstory.com/practicalneo4j for Python and
configured it with your local application environment, you can skip ahead to the next section, “Bottle Application
Configuration”. Otherwise, you will need to go back to the section in this chapter titled “ Python and Neo4j
Development Environment ” section and set up your local environment in order to follow the examples in the sample
application.
Bottle Application Configuration
Before diving into the code examples, you need to update the configuration for the Bottle application. In Eclipse (or
the IDE you are using), open the file {PROJECTROOT}/app/bottle/graphstory.py and edit the GraphStory connection
string information. If you are using a free account from graphstory.com , you will change the username, password,
and URL in Listing 9-12 with the one provided in your graph console on graphstory.com .
 
 
Search WWH ::




Custom Search