Accessing the embedded Neo4j from Python
Python is getting increasingly popular nowadays, and, in this recipe, we will learn how to connect to the Neo4j embedded graph server from the Python client.
Getting ready
Embedded Neo4j is an excellent binding module available in Python to access the Neo4j embedded database. The following steps describe the use of this module:
Install the
JPype
Python module, as shown in the following command:$ sudo apt-get install python-jpype
It can also be installed from the source available at http://sourceforge.net/projects/jpype/files/JPype/.
Install Neo4j embedded using either
pip
oreasy_install
, as follows:$ pip install neo4j-embedded $ easy_install neo4j-embedded
How to do it...
Perform the following steps in order to access Neo4j from Python:
Let's create our first node using the following code:
import neo4j db_obj = neo4j.GraphDatabase(DB_PATH) # All write operations on graph database happens in transaction with db_obj.transaction: node = db_obj.node(name...