Skill

Load Graph Database Data with Cypher Queries

Load data from graph databases using Cypher queries. Compatible with Neo4j, AWS Neptune, and Memgraph. Integrates with LlamaIndex and LangChain.

Works with neo4jaws neptunememgraphllama indexlangchain

57
Spark score
out of 100
Updated 4 days ago
Version 0.14.22
Models

Add to Favorites

Why it matters

Ingest structured data from graph databases like Neo4j, AWS Neptune, and Memgraph into your AI applications. This asset executes custom Cypher queries to extract and format data, making it readily available for LLM-based analysis and knowledge graph construction.

Outcomes

What it gets done

01

Connect to various graph database endpoints (Neo4j, Neptune, Memgraph) using provided credentials.

02

Execute user-defined Cypher queries with optional parameters to retrieve specific data.

03

Transform query results into a YAML string representation for document ingestion.

04

Integrate seamlessly with LlamaIndex for data loading or as a tool within LangChain agents.

Install

Add it to your toolbox

Run in your project directory:

curl -fsSL https://spark.entire.vc/get/li-reader-readers-graphdb-cypher | bash

Capabilities

What this skill does

Query a database

Writes and executes SQL or NoSQL queries on databases.

Extract

Pulls structured data fields from unstructured text.

Knowledge graph

Builds and queries entity-relationship graphs.

RAG index

Chunks, embeds, and indexes documents for semantic retrieval.

Overview

Graph Database Cypher Loader

What it does

This loader populates documents from results of Cypher queries from a Graph database endpoint. The user specifies a GraphDB endpoint URL with optional credentials to initialize the reader. By declaring the Cypher query and optional parameters, the loader can fetch the nested result docs. The results will be turned into a YAML representation to be turned into a string for the document.

How it connects

Use this loader to ingest data from graph databases like Neo4j, AWS Neptune, or Memgraph.

Source README

Graph Database Cypher Loader

pip install llama-index-readers-graphdb-cypher

This loader populates documents from results of Cypher queries from a Graph database endpoint.
The user specifies a GraphDB endpoint URL with optional credentials to initialize the reader.
By declaring the Cypher query and optional parameters the loader can fetch the nested result docs.
The results will be turned into a yaml representation to be turned into a string for the document.

The approach should work for Neo4j, AWS Neptune and Memgraph.

Usage

Here's an example usage of the GraphDBCypherReader.

You can test out queries directly with the Neo4j labs demo server: demo.neo4jlabs.com or with a free instance https://neo4j.com/aura

import os

from llama_index.readers.graphdb_cypher import GraphDBCypherReader

uri = "neo4j+s://demo.neo4jlabs.com"
username = "stackoverflow"
password = "stackoverflow"
database = "stackoverflow"

query = """
    MATCH (q:Question)-[:TAGGED]->(:Tag {name:$tag})
    RETURN q.title as title
    ORDER BY q.createdAt DESC LIMIT 10
"""
reader = GraphDBCypherReader(uri, username, password, database)
documents = reader.load_data(query, parameters={"tag": "lua"})

This loader is designed to be used as a way to load data into LlamaIndex
and/or subsequently used as a Tool in a LangChain Agent.

It uses the Neo4j Graph Database for the Cypher queries.

Discussion

Questions & comments · 0

Sign In Sign in to leave a comment.