Skip to main content

openGauss Vector Database Adapter

This is a community-contributed adapter for integrating openGauss DataVec with Cognee.

About openGauss

openGauss is an open-source relational database with ACID transactions and built-in vector capabilities via DataVec (6.0.0+). It provides native VECTOR(n) type, HNSW / IVFFLAT / IVFPQ indexes, and hybrid SQL + vector similarity search — all in a single database.

Installation

  1. Install the required dependencies:

    # Option 1: Install dependencies directly
    pip install psycopg2-binary>=2.9.9
    
    # Option 2: Install as a package (if published)
    pip install cognee-community-vector-adapter-opengauss
    
    # Option 3: Install from source
    cd packages/vector/opengauss
    pip install .
    
  2. Import and register the adapter in your code:

    from cognee_community_vector_adapter_opengauss import register
    

Setup

Start an openGauss container:

docker run -d \
    --name opengauss \
    --privileged=true \
    --restart=always \
    -p 5432:5432 \
    -e GS_PASSWORD=openGauss@123 \
    -v ./opengauss:/var/lib/opengauss/data \
    opengauss/opengauss:7.0.0-RC1

No additional extension required — DataVec is built in.

Configuration

Create a .env file from the template:

cp .env.example .env
# Edit .env with your LLM / embedding / database settings

Configure Cognee to use openGauss:

from dotenv import load_dotenv
from cognee import config
from cognee_community_vector_adapter_opengauss import register

load_dotenv()

config.set_vector_db_config(
    {
        "vector_db_provider": "opengauss",
        "vector_db_url": "postgresql://gaussdb:openGauss%40123@localhost:5432/postgres",
    }
)

Required environment variables:

OPENGAUSS_URL=postgresql://gaussdb:OpenGauss%40123@localhost:5432/postgres
ENABLE_BACKEND_ACCESS_CONTROL=false

LLM and embedding providers must also be configured — see the Cognee docs.

Optional openGauss settings (all have defaults):

OPENGAUSS_SCHEMA_NAME=cognee           # Schema for vector tables
OPENGAUSS_INDEX_TYPE=HNSW              # HNSW | IVFFLAT | IVFPQ | HNSW-PQ
OPENGAUSS_DISTANCE_STRATEGY=COSINE     # COSINE | EUCLIDEAN | MANHATTAN | INNER_PROD
OPENGAUSS_CREATE_INDEX=false           # Enable when index implementation is stable

Usage Example

import asyncio
import os
import pathlib
from dotenv import load_dotenv
from cognee import add, cognify, config, search, SearchType
from cognee_community_vector_adapter_opengauss import register

load_dotenv()


async def main():
    # Set working directories
    root = pathlib.Path(__file__).parent
    config.system_root_directory(str(root / ".cognee_system"))
    config.data_root_directory(str(root / ".cognee_data"))

    # Configure openGauss
    config.set_vector_db_config(
        {
            "vector_db_provider": "opengauss",
            "vector_db_url": os.getenv(
                "OPENGAUSS_URL",
                "postgresql://gaussdb:openGauss%40123@localhost:5432/postgres",
            ),
        }
    )

    # Add and process data
    await add("Natural language processing is a subfield of AI.")
    await cognify()

    # Search
    results = await search("Tell me about NLP", query_type=SearchType.GRAPH_COMPLETION)
    print(results)


asyncio.run(main())

Features

  • ACID transactions: Full transactional guarantees for vector writes
  • Multiple index types: HNSW, IVFFLAT, IVFPQ, and HNSW-PQ index algorithms
  • Hybrid search: Combine SQL filtering with vector similarity search in a single query
  • Schema isolation: All vector tables live in a configurable cognee schema
  • Self-contained: No separate vector database or extension required — DataVec is built in

Testing

Run the tests to verify the adapter works correctly:

python tests/test_opengauss.py

Dependencies

  • psycopg2-binary>=2.9.9: PostgreSQL database adapter for Python

Production Deployment

Deploy openGauss on bare metal or Kubernetes for high availability. It supports active-standby replication and automatic failover. See the openGauss installation guide for details.

Support

For issues specific to this adapter:

  1. Check the openGauss documentation
  2. Create an issue in the main Cognee repository with the "community-adapter" label
  3. Refer to the examples/ and tests/ directories for usage patterns

License

This adapter is licensed under the MIT license, same as the main Cognee project.

Download files

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

Source Distribution

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_vector_adapter_opengauss-0.2.0.tar.gz.

File metadata

File hashes

Hashes for cognee_community_vector_adapter_opengauss-0.2.0.tar.gz
Algorithm Hash digest
SHA256 e1d4c7d6c6ed694249218aebee6df99a3ceff86a2897fca8fe56906187da28c0
MD5 8ec24b40a15407b8723a828cb2abd513
BLAKE2b-256 6ee2a0ab7ff8aa7885baec8cd7bf5c7c2d413579549d149151493be2d61c8cf2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cognee_community_vector_adapter_opengauss-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4d0c42872d45f3ade386628ad58e7b2878caf83f6cb266886c9bef8433389a4d
MD5 107e5d424ca0ecd6bc9d1471ffdbad8d
BLAKE2b-256 3647717fdc94d78ae14d35e20d35adee7aa95b10e3251c9d4e7c1a72686fa110

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