Duffy SDK¶
Python SDK for Apache AGE + pgvector on PostgreSQL.
Graph queries, vector search, and hybrid graph+vector operations — all in one PostgreSQL instance.
Installation¶
pip install duffy
# With pandas support
pip install duffy[pandas]
# With all optional dependencies
pip install duffy[all]
Quick Example¶
import duffy
db = duffy.connect("postgresql://localhost:5433/mydb", 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()
What's Inside¶
- Quick Start — Get up and running in 5 minutes
- API Reference — Full method signatures and parameters
- Integrations — LangChain, LlamaIndex, NetworkX, PyTorch Geometric
Requirements¶
- Python 3.10+
- PostgreSQL with Apache AGE and pgvector extensions
License¶
Apache 2.0