Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
36c4520
[wip] Add postgres backend for graphs.
DanielNScott Mar 24, 2026
f0396d5
[wip] Raise where postgres graphDB incompatible with graphDB consumers
DanielNScott Mar 24, 2026
4347a95
[pass] Add tests and fixes for postgres graph adapter.
DanielNScott Mar 25, 2026
b6a533a
[pass] Apply formatting guidelines via ruff.
DanielNScott Mar 25, 2026
a69929f
[pass] Update documentation
DanielNScott Mar 25, 2026
0781aaf
[wip] Batch SQL operations in postgres graph adapter.
DanielNScott Mar 30, 2026
fe1c3b0
[pass] Unify schema definition into SQLAlchemy Core table objects.
DanielNScott Mar 30, 2026
1a846b6
[pass] Address PR #2506 review comments on postgres graph adapter.
DanielNScott Apr 1, 2026
36837f7
[pass] Address new PR review nitpicks.
DanielNScott Apr 1, 2026
f19e7d2
Merge branch 'dev' into feature/cog-4463-graph-aware-embeddings-imple…
lxobr Apr 7, 2026
986cfd7
[pass] Decouple postgres graph adapter from relational layer.
DanielNScott Apr 8, 2026
5335918
Merge branch 'feature/cog-4463-graph-aware-embeddings-implement-minim…
DanielNScott Apr 8, 2026
5f6ae51
[pass] Implement get_neighborhood and fix interface compliance after …
DanielNScott Apr 8, 2026
6f33e6f
Merge branch 'dev' into feature/cog-4463-graph-aware-embeddings-imple…
lxobr Apr 8, 2026
3a2b785
[pass] Reformat via pre-commit hooks
DanielNScott Apr 8, 2026
eafce01
Merge branch 'dev' into feature/cog-4463-graph-aware-embeddings-imple…
lxobr Apr 8, 2026
34a4ffe
[pass] Move postgres-dependent tests to e2e/postgres directory.
DanielNScott Apr 8, 2026
da6a001
Merge remote-tracking branch 'upstream/feature/cog-4463-graph-aware-e…
DanielNScott Apr 9, 2026
f784a7a
[pass] Implement AND logic for node_name_filter_operator in get_nodes…
DanielNScott Apr 10, 2026
6b2af3f
[pass] Address CodeRabbit review items on PR #2584.
DanielNScott Apr 10, 2026
1941db7
[pass] Tweaks: batch dedup, node tuple shape, and triplet ordering.
DanielNScott Apr 10, 2026
46201d0
Merge branch 'dev' into feature/cog-4463-graph-aware-embeddings-imple…
lxobr Apr 10, 2026
02977a7
Merge branch 'dev' into feature/cog-4463-graph-aware-embeddings-imple…
lxobr Apr 10, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions .github/workflows/graph_db_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ on:
type: string
default: "all"
description: "Which vector databases to test (comma-separated list or 'all')"
python-version:
required: false
type: string
default: "3.11.x"
description: "Python version to use for testing"
ci-image:
required: false
type: string
Expand Down Expand Up @@ -66,6 +71,68 @@ jobs:
EMBEDDING_API_VERSION: ${{ secrets.EMBEDDING_API_VERSION }}
run: uv run pytest cognee/tests/unit/interfaces/graph/test_weighted_edges.py -v

run-postgres-tests:
name: Postgres Graph Tests
runs-on: ubuntu-22.04
if: ${{ inputs.databases == 'all' || contains(inputs.databases, 'postgres') }}
services:
postgres:
image: postgres:16
env:
POSTGRES_USER: cognee
POSTGRES_PASSWORD: cognee
POSTGRES_DB: cognee_db
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Check out
uses: actions/checkout@v6
with:
fetch-depth: 0

- name: Cognee Setup
uses: ./.github/actions/cognee_setup
with:
python-version: ${{ inputs.python-version }}

- name: Run Postgres Adapter Unit Tests
env:
DB_PROVIDER: postgres
DB_HOST: localhost
DB_PORT: 5432
DB_USERNAME: cognee
DB_PASSWORD: cognee
DB_NAME: cognee_db
run: uv run pytest cognee/tests/e2e/postgres/test_postgres_adapter.py -v

- name: Run Postgres Graph E2E Test
env:
ENV: 'dev'
GRAPH_DATABASE_PROVIDER: "postgres"
GRAPH_DATABASE_URL: "postgresql+asyncpg://cognee:cognee@localhost:5432/cognee_db"
DB_PROVIDER: postgres
DB_HOST: localhost
DB_PORT: 5432
DB_USERNAME: cognee
DB_PASSWORD: cognee
DB_NAME: cognee_db
ENABLE_BACKEND_ACCESS_CONTROL: 'false'
LLM_MODEL: ${{ secrets.LLM_MODEL }}
LLM_ENDPOINT: ${{ secrets.LLM_ENDPOINT }}
LLM_API_KEY: ${{ secrets.LLM_API_KEY }}
LLM_API_VERSION: ${{ secrets.LLM_API_VERSION }}
EMBEDDING_DIMENSIONS: 300
EMBEDDING_MODEL: ${{ secrets.EMBEDDING_MODEL }}
EMBEDDING_ENDPOINT: ${{ secrets.EMBEDDING_ENDPOINT }}
EMBEDDING_API_KEY: ${{ secrets.EMBEDDING_API_KEY }}
EMBEDDING_API_VERSION: ${{ secrets.EMBEDDING_API_VERSION }}
run: uv run python ./cognee/tests/e2e/postgres/test_graphdb_postgres.py

run-neo4j-tests:
name: Neo4j Tests
runs-on: ubuntu-22.04
Expand Down
9 changes: 7 additions & 2 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ All data flows through task-based pipelines (`cognee/modules/pipelines/`). Tasks

#### 2. Interface-Based Database Adapters
Multiple backends are supported through adapter interfaces:
- **Graph**: Kuzu (default), Neo4j, Neptune via `GraphDBInterface`
- **Graph**: Kuzu (default), Neo4j, Neptune, Postgres via `GraphDBInterface`
- **Vector**: LanceDB (default), ChromaDB, PGVector via `VectorDBInterface`
- **Relational**: SQLite (default), PostgreSQL

Expand Down Expand Up @@ -268,7 +268,7 @@ VECTOR_DB_URL=postgresql://cognee:cognee@localhost:5432/cognee_db
```

#### Graph Databases
Supported: kuzu (default), neo4j, neptune, kuzu-remote
Supported: kuzu (default), neo4j, neptune, kuzu-remote, postgres
```bash
# Neo4j (requires neo4j extra: pip install cognee[neo4j])
GRAPH_DATABASE_PROVIDER=neo4j
Expand All @@ -282,6 +282,11 @@ GRAPH_DATABASE_PROVIDER=kuzu-remote
GRAPH_DATABASE_URL=http://localhost:8000
GRAPH_DATABASE_USERNAME=your_username
GRAPH_DATABASE_PASSWORD=your_password

# Postgres (requires postgres extra: pip install cognee[postgres])
# Does not support raw Cypher queries, natural language search, or Graphiti.
GRAPH_DATABASE_PROVIDER=postgres
GRAPH_DATABASE_URL=postgresql+asyncpg://cognee:cognee@localhost:5432/cognee_db
```
Comment thread
coderabbitai[bot] marked this conversation as resolved.

### LLM Provider Configuration
Expand Down
10 changes: 9 additions & 1 deletion cognee/infrastructure/databases/graph/get_graph_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,14 @@ def _create_graph_engine(
graph_database_allow_anonymous=graph_database_allow_anonymous,
)

elif graph_database_provider == "postgres":
if not graph_database_url:
raise EnvironmentError("Missing required Postgres GRAPH_DATABASE_URL.")

from .postgres.adapter import PostgresAdapter

return PostgresAdapter(connection_string=graph_database_url)

elif graph_database_provider == "kuzu":
if not graph_file_path:
raise EnvironmentError("Missing required Kuzu database path.")
Expand Down Expand Up @@ -199,5 +207,5 @@ def _create_graph_engine(

raise EnvironmentError(
f"Unsupported graph database provider: {graph_database_provider}. "
f"Supported providers are: {', '.join(list(supported_databases.keys()) + ['neo4j', 'kuzu', 'kuzu-remote', 'neptune', 'neptune_analytics'])}"
f"Supported providers are: {', '.join(list(supported_databases.keys()) + ['neo4j', 'kuzu', 'kuzu-remote', 'postgres', 'neptune', 'neptune_analytics'])}"
)
Empty file.
Loading
Loading