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
-
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 .
-
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
cogneeschema - 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:
- Check the openGauss documentation
- Create an issue in the main Cognee repository with the "community-adapter" label
- Refer to the
examples/andtests/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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cognee_community_vector_adapter_opengauss-0.2.0.tar.gz.
File metadata
- Download URL: cognee_community_vector_adapter_opengauss-0.2.0.tar.gz
- Upload date:
- Size: 10.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
poetry/2.4.1 CPython/3.10.18 Darwin/24.1.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e1d4c7d6c6ed694249218aebee6df99a3ceff86a2897fca8fe56906187da28c0
|
|
| MD5 |
8ec24b40a15407b8723a828cb2abd513
|
|
| BLAKE2b-256 |
6ee2a0ab7ff8aa7885baec8cd7bf5c7c2d413579549d149151493be2d61c8cf2
|
File details
Details for the file cognee_community_vector_adapter_opengauss-0.2.0-py3-none-any.whl.
File metadata
- Download URL: cognee_community_vector_adapter_opengauss-0.2.0-py3-none-any.whl
- Upload date:
- Size: 9.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
poetry/2.4.1 CPython/3.10.18 Darwin/24.1.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4d0c42872d45f3ade386628ad58e7b2878caf83f6cb266886c9bef8433389a4d
|
|
| MD5 |
107e5d424ca0ecd6bc9d1471ffdbad8d
|
|
| BLAKE2b-256 |
3647717fdc94d78ae14d35e20d35adee7aa95b10e3251c9d4e7c1a72686fa110
|