Learn

How to query Graph data in Redis using Python

Ajeet Raina
Author
Ajeet Raina, Former Developer Growth Manager at Redis

RedisGraph is the fastest graph database that processes complex graph operations in real time, 10x – 600x faster than any other graph database. Show how your data is connected through multiple visualization integrations including RedisInsight, Linkurious, and Graphileon. Query graphs using the industry-standard Cypher query language and easily use graph capabilities from application code.

RedisGraph Python Client#

The 'redisgraph-py' is a package that allows querying Graph data in a Redis database that is extended with the RedisGraph module. The package extends redisgraph-py's interface with RedisGraph's API

Follow the steps below to get started with RedisGraph with Python:

Step 1. Run Redis Stack Docker container#

Step 2. Verify if RedisGraph module is loaded#

Step 3. Loading the Python Module#

Step 4. Write a python code#

Step 5. Execute the Python Script#

Step 6. Monitor the Graph query#

Let us comment out the last line. Try to query Graph data over over RedisInsight.

Step 7. Install RedisInsight#

Run the RedisInsight container. The easiest way is to run the following command:

Step 8. Accessing RedisInsight#

Next, point your browser to http://localhost:8001.

Step 9. Run the Graph Query#

You can use the limit clause to limit the number of records returned by a query:

MATCH (n) RETURN n LIMIT 1

Step 10. Run the Graph Query with no LIMIT#

MATCH (n) RETURN n

References#

  • Learn more about RedisGraph in the Quickstart tutorial.