Python SDK for Apache AGE + pgvector — graph and vector queries on PostgreSQL
Project description
Piggie
Python SDK for Apache AGE + pgvector on PostgreSQL.
Graph queries, vector search, and hybrid graph+vector operations — all in one PostgreSQL instance.
Quick Start
import piggie
db = piggie.connect("postgresql://localhost:5433/piggie", graph="my_graph")
# Cypher queries → DataFrames
df = db.cypher("MATCH (n:Person) RETURN n.name, n.age").to_df()
# Vector search
results = db.vector_search("documents", "embedding", query_vec, k=10).to_df()
# Hybrid: graph traversal + vector similarity
results = db.hybrid_search(
cypher="MATCH (p:Paper)-[:CITES]->(cited) RETURN cited",
vector_table="papers",
vector_column="abstract_embedding",
query_vector=query_vec,
k=10,
).to_df()
Installation
pip install piggie
# With pandas support
pip install piggie[pandas]
# With all optional dependencies
pip install piggie[all]
Benchmarks
We benchmarked AGE + pgvector against Neo4j, Kuzu, and NebulaGraph across 12 workloads at three scales (10K, 100K, 1M). AGE won all 12 workloads at every scale. At 1M nodes:
| Workload | AGE | Neo4j | Speedup |
|---|---|---|---|
| Point Lookup | 0.29ms | 0.97ms | 3x |
| Pattern Match | 0.14ms | 1.8ms | 13x |
| VLE Traversal | 0.18ms | 0.62ms | 3x |
| Concurrent Queries | 52ms | 1,323ms | 25x |
| Bulk Load | 59ms | 133ms | 2x |
The Piggie SDK also won 14/16 algorithm benchmarks against Neo4j GDS, using igraph (C) and networkit (C++) backends.
Read the full analysis: Can One PostgreSQL Replace Your Graph Database and Your Vector Database?
Graph Algorithms
19 algorithms across 7 categories with automatic backend selection:
# Auto-selects igraph C backend
df = db.centrality(measure="betweenness")
# Auto-selects networkit C++ backend
df = db.centrality(measure="closeness")
# Community detection
df = db.community(method="louvain")
Backends: igraph (C), networkit (C++), NetworkX (Python). The SDK detects installed backends and routes each algorithm to the fastest available implementation.
Integrations
- LangChain —
PiggieVectorStoreandPiggieGraphStorefor RAG pipelines - LlamaIndex —
PiggieGraphStore(triplets) andPiggiePropertyGraphStore(labeled property graph) - NetworkX —
to_networkx()conversion + built-in PageRank, community detection, shortest path, centrality - PyTorch Geometric —
FeatureStoreandGraphStorefor GNN training on AGE data
Notebooks
| Notebook | Description |
|---|---|
| Quickstart | Getting started with Piggie |
| Hybrid Search | Graph + vector search combined |
| Bulk Load | Bulk load and export |
| Algorithms | Graph algorithms with igraph/networkit backends |
| RAG Pipeline | RAG with LlamaIndex and LangChain |
| GNN Training | GNN training with PyTorch Geometric |
Documentation
- Quick Start — 5-minute getting-started guide
- API Reference — full method signatures and parameters
- Graph Algorithms — algorithm catalog and backend selection
- Integrations — LangChain, LlamaIndex, NetworkX, PyG
Community
- GitHub Discussions — questions, ideas, show and tell
- Issue Tracker — bug reports and feature requests
- Contributing Guide — how to set up and contribute
Requirements
- Python 3.10+
- PostgreSQL with Apache AGE and pgvector extensions
License
Apache 2.0
Project details
Release history Release notifications | RSS feed
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 piggie-0.5.0.tar.gz.
File metadata
- Download URL: piggie-0.5.0.tar.gz
- Upload date:
- Size: 578.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6148fa5a18bfde64f4709d966a7d6aeae460a7c21f85cc3940fae6140a71cb88
|
|
| MD5 |
be134dcde07e2cd8c14102c885ef5f9e
|
|
| BLAKE2b-256 |
32e82d542c4b86f7ba856444459a5d42257b7aba3884d2478429e59e7da0abdf
|
File details
Details for the file piggie-0.5.0-py3-none-any.whl.
File metadata
- Download URL: piggie-0.5.0-py3-none-any.whl
- Upload date:
- Size: 71.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ed280739a94214be3ec2e7245926f0f37301262f7f724f6735113ffb047ebff4
|
|
| MD5 |
83423b8dd2e4a53112a359a3c60ea8d0
|
|
| BLAKE2b-256 |
bd379db61bdf6f312a9f6cf2a24ad7f077aa79a1600e10ab4bfd99b6f4d9b723
|