Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Neo4j Cookbook

You're reading from   Neo4j Cookbook Harness the power of Neo4j to perform complex data analysis over the course of 75 easy-to-follow recipes

Arrow left icon
Product type Paperback
Published in May 2015
Publisher
ISBN-13 9781783287253
Length 226 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Ankur Goel Ankur Goel
Author Profile Icon Ankur Goel
Ankur Goel
Arrow right icon
View More author details
Toc

Table of Contents (12) Chapters Close

Preface 1. Getting Started with Neo4j 2. Connecting to Neo4j FREE CHAPTER 3. The Cypher Query Language 4. Data Modeling and Leveraging with Neo4j 5. Mining the Social Treasure 6. Developing Location-based Services with Neo4j 7. Visualization of Graphs 8. Industry Usages of Neo4j 9. Neo4j Administration and Maintenance 10. Scaling Neo4j Index

Accessing Neo4j from Python using the REST bindings


The REST interface is widely used and in this recipe, we will learn how to access Neo4j from Python using the REST Bindings.

Getting ready

The py2neo module (http://py2neo.org/2.0/) is an excellent Python binding module used to connect to the Neo4j REST API server.

The py2neo module can be installed from both pip and easy_install, as shown here:

$ pip install py2neo
$ easy_install py2neo

How to do it...

The following steps will get you started with this recipe:

  1. First, we will create our first node assuming the default installation, as shown in the following code:

    from py2neo import neo4j
    graph = neo4j.GraphDatabaseService(ENDPOINT_URL)
    graph.create(node(name="A")
  2. Next, let's create our first relation using the py2neo module:

    from py2neo import neo4j
    graph = neo4j.Graph(ENDPOINT_URL)
    graph.create(node(name="A"),
                 node(name="B"))
    rel(1, "PLAYS WITH", 2)
    rel(2, "FATHER OF", 1)
You have been reading a chapter from
Neo4j Cookbook
Published in: May 2015
Publisher:
ISBN-13: 9781783287253
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image