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

Metadata

Release files for cognee-community-graph-adapter-pggraph 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cognee-community-graph-adapter-pggraph 0.2.0
File Size Uploaded Provenance
cognee_community_graph_adapter_pggraph-0.2.0.tar.gz 207.6 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for cognee-community-graph-adapter-pggraph 0.2.0
File Interpreter ABI Platform
cognee_community_graph_adapter_pggraph-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 216.4 kB

Release files / cognee_community_graph_adapter_pggraph-0.2.0.tar.gz

Download URL cognee_community_graph_adapter_pggraph-0.2.0.tar.gz
Size 207.6 kB
Tags Source
SHA-256 checksum
How to use checksums
101b1405392703ddf57798cee78cd54f3f307911d4385c9e58a0f943362f2893
BLAKE2b-256 checksum
How to use checksums
e1207d2b28227556fc5101b5857374a8e592b64bfb2cdb2fbc7f940d74f4e989
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.4.1 CPython/3.10.18 Darwin/24.1.0

Release files / cognee_community_graph_adapter_pggraph-0.2.0-py3-none-any.whl

Download URL cognee_community_graph_adapter_pggraph-0.2.0-py3-none-any.whl
Size 8.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
77fa26087f24e42b9458f00ac01664bfca1c834fbe76737156a269912b8167c9
BLAKE2b-256 checksum
How to use checksums
697022209f181dfd144cac231436ac20de8e14219fa5c64bd8d6177ffe91d129
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.4.1 CPython/3.10.18 Darwin/24.1.0

Security for cognee-community-graph-adapter-pggraph 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files No provenance

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