Skip to main content

Cognee Community Graph Adapter - pgGraph (experimental)

Use pgGraph as a graph traversal layer on top of Cognee's standard Postgres graph tables (graph_node, graph_edge).

Status: Experimental. Works without the pgGraph extension (SQL fallback). Install pgGraph on Postgres for accelerated graph.traverse() queries.

Installation

pip install cognee-community-graph-adapter-pggraph asyncpg

Or from this directory:

uv sync

Quick demo (Docker + adapter test)

cd examples/docker
docker compose up -d
cd ..
export GRAPH_DATABASE_PROVIDER=pggraph
export GRAPH_DATABASE_HOST=localhost
export GRAPH_DATABASE_PORT=5433
export GRAPH_DATABASE_NAME=cognee
export GRAPH_DATABASE_USERNAME=cognee
export GRAPH_DATABASE_PASSWORD=cognee
export DB_PROVIDER=postgres
export DB_HOST=localhost
export DB_PORT=5433
export DB_NAME=cognee
export DB_USERNAME=cognee
export DB_PASSWORD=cognee
export ENABLE_BACKEND_ACCESS_CONTROL=false
uv run python examples/example.py

Usage

import asyncio
import os
import cognee
from cognee.infrastructure.databases.graph import get_graph_engine
from cognee_community_graph_adapter_pggraph import register


async def main():
    register()
    cognee.config.set_graph_database_provider("pggraph")
    cognee.config.set_graph_db_config(
        {
            "graph_database_host": os.getenv("GRAPH_DATABASE_HOST", "localhost"),
            "graph_database_port": int(os.getenv("GRAPH_DATABASE_PORT", "5433")),
            "graph_database_name": os.getenv("GRAPH_DATABASE_NAME", "cognee"),
            "graph_database_username": os.getenv("GRAPH_DATABASE_USERNAME", "cognee"),
            "graph_database_password": os.getenv("GRAPH_DATABASE_PASSWORD", "cognee"),
        }
    )

    graph = await get_graph_engine()
    await graph.initialize()
    # ... add_nodes, build_graph(), get_neighbors, etc.


asyncio.run(main())

Environment variables

Variable Description
GRAPH_DATABASE_PROVIDER Set to pggraph after calling register()
GRAPH_DATABASE_HOST / PORT / NAME / USERNAME / PASSWORD Postgres connection
PGGRAPH_BUILD_MODE manual (default), on_write, or scheduled
ENABLE_BACKEND_ACCESS_CONTROL Set false for single-database demos

pgGraph extension

The adapter checks pg_available_extensions before CREATE EXTENSION graph. To use the real extension, run Postgres with pgGraph installed — see pgGraph quickstart.

Core Cognee integration

This community package registers via use_graph_adapter("pggraph", PgGraphAdapter). A future upstream PR to topoteretes/cognee may add native GRAPH_DATABASE_PROVIDER=pggraph support.

Related

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cognee_community_graph_adapter_pggraph-0.2.0.tar.gz (207.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file cognee_community_graph_adapter_pggraph-0.2.0.tar.gz.

File metadata

File hashes

Hashes for cognee_community_graph_adapter_pggraph-0.2.0.tar.gz
Algorithm Hash digest
SHA256 101b1405392703ddf57798cee78cd54f3f307911d4385c9e58a0f943362f2893
MD5 e3ed6d2e68fb809b04c211315c8484d3
BLAKE2b-256 e1207d2b28227556fc5101b5857374a8e592b64bfb2cdb2fbc7f940d74f4e989

See more details on using hashes here.

File details

Details for the file cognee_community_graph_adapter_pggraph-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for cognee_community_graph_adapter_pggraph-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 77fa26087f24e42b9458f00ac01664bfca1c834fbe76737156a269912b8167c9
MD5 63c3cf1c2a93ef8d9d65a302185beace
BLAKE2b-256 697022209f181dfd144cac231436ac20de8e14219fa5c64bd8d6177ffe91d129

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page