Working with Neo4j using Python

neo4j database

NoSQL databases are in demand these days because of various advantages, to list a few of them:

  1. They can handle large volumes of data at high speed with a scale-out architecture
  2. Stores unstuctured, semi-structured, or structured data
  3. Support multiple data structures

Neo4j is one of noSQL Graph Database. Let us take a look at some of its advantages below:

  1. Easy representation of data: Neo4j provides a very easy way to represent relationships and semi-structured data.
  2. Faster Execution: Neo4j is fast because more connected data is easy to retrieve and navigate.

As python is becoming a handy language to build applications, dealing with data & much more. It is important to learn how we can connect and play with the data coming from NoSQL databases.

In this Blog, we will learn how we can extract data from Neo4j database.

To begin with it, we first need to install neo4j library/connector:

Go to command prompt or anaconda prompt if you are using anaconda’s jupyter or spyder.
Run below command:

We will extract movie data from neo4j default database:

In above graph, we can see there are multiple nodes for Actors and Movies. Also, there are relationships defined as ‘ACTED IN’, ‘DIRECTED’, etc.

Lets jump into code:

Now, data has been stored in a list and is ready to be consumed as per user’s specific usecase.

NOTE: If you wish to run any other cypher(query language for Neo4j) statement/s, you can run in similar manner. Below is an example:

Hope this tutorial helped you to work with Neo4j using python.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store