Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Embedded Neo4j Graph Database Now Works in Python

DZone's Guide to

Embedded Neo4j Graph Database Now Works in Python

· Java Zone
Free Resource

Microservices! They are everywhere, or at least, the term is. When should you use a microservice architecture? What factors should be considered when making that decision? Do the benefits outweigh the costs? Why is everyone so excited about them, anyway?  Brought to you in partnership with IBM.

First of all, we’re really sorry. We have been saying that Python support for the embedded database is coming in “a few weeks” or “next month" for over half a year now, and so far, you have waited patiently, and you have waited in vain.


We promise to not give promises we can’t keep again, and we hope ya’ll know that we love Python just as much as the next guy.


Now, finally, the absolutely latest and greatest version of the embedded Neo4j database works in Python, and we’ve put a bunch of effort into ensuring it stays that way. The new bindings are constantly tested against each new build of the database, and are set up to deploy to PyPy as often as we all like them to.


The API is very similar to the original neo4j.py API. We also borrowed some of the API methods introduced in neo4j-rest-client, to make switching between the two as easy as possible.


This is a first release, so there may still be bugs lurking - please make sure to report any that you encounter and ideas for improvements to the project issue tracker!


Quick look

 
Here is a quick look at how you use neo4j-embedded.

from neo4j import GraphDatabase

db = GraphDatabase(‘/my/db/location’)

with db.transaction:
    oscar = db.node(name=’Oscar Wilde’)
    jacob = db.node(name=’Jacob’)

    # Create a relationship
    oscar.impressed_by_blogging_skills_of(jacob)
db.shutdown()
 

Requirements


The new bindings are tested on CPython 2.7.2 on Windows and Linux, but should work on Python 2.6 branches as well. 


You’ll need JPype installed to bridge the gap to Java land, details about how to set that up can be found in the installation instructions.


Jython support is on the todo list, but because Neo4j uses Java’s ServiceLoader API (which does not currently work in Jython) it will have to wait until we find a good workaround.


Getting started


Full instructions for how to install and get started can be found in the Neo4j Manual. For feedback, hints and contributions, don’t hesitate to ask on the Neo4j Forums.


Happy Hacking!

Discover how the Watson team is further developing SDKs in Java, Node.js, Python, iOS, and Android to access these services and make programming easy. Brought to you in partnership with IBM.

Topics:

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

X

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}