pgvecto.rs (Python)

Python client for the pgvecto.rs Postgres vector extension, with SQLAlchemy, Psycopg 3, and Django support.

SDK
PyPI
v0.2.2
2,183stars
Apache License 2.0

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
47/100Fair
Development Activity0
Maintenance48
Community48
Maturity52
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
74/100Good
Architecture75
Code Quality72
Innovation74
Learning Curve80

pgvecto-rs is the Python binding for pgvecto.rs, a Rust-based Postgres extension for vector similarity search. It lets Python applications store and query high-dimensional vectors directly in Postgres through the ORM and driver they already use — SQLAlchemy, Psycopg 3, or Django — without a separate vector database.

The library registers the extension’s vector column types (dense, sparse, half-precision FP16, and binary vectors), handles conversion between Python/NumPy values and the wire format, and exposes the distance operators needed for nearest-neighbor search. Note that pgvecto.rs is now in maintenance mode; its maintainers recommend migrating to the successor extension, VectorChord.

What You Get

  • SQLAlchemy column types for dense, sparse, FP16, and binary vectors
  • Psycopg 3 adapters with INSERT and high-throughput COPY support
  • A Django field for storing and querying vectors in models
  • Automatic conversion between Python lists / NumPy arrays and the extension wire format
  • Distance-operator helpers for building nearest-neighbor similarity queries
  • A standalone SDK client for using the extension without an ORM

Common Use Cases

  • Adding semantic search to an existing Postgres-backed application
  • Storing embeddings for retrieval-augmented generation (RAG) pipelines
  • Running nearest-neighbor queries through SQLAlchemy or Django models
  • Bulk-loading large embedding sets with Psycopg 3 COPY
  • Combining vector search with relational filters and joins in one query

Under The Hood

Architecture — The pgvecto_rs Python package is a thin integration layer that maps Postgres vector column types exposed by the pgvecto.rs extension onto three popular data-access stacks: SQLAlchemy, Psycopg 3, and Django. It registers custom column types (Vector, sparse vector, FP16, and binary vector) and adapters so that vectors round-trip between Python lists/NumPy arrays and the extension’s on-disk representation, and it builds the SQL for distance operators used in similarity queries.

Tech Stack — Written in Python and distributed on PyPI, it depends on NumPy for vector handling and integrates optionally with SQLAlchemy, Psycopg 3, and Django. The underlying pgvecto.rs extension it targets is a Rust Postgres extension built on pgrx that performs the actual indexing and SIMD-accelerated search.

Code Quality — The binding is a focused, small-surface library with per-integration adapters kept in separate modules so applications only pull in the ORM glue they use. Note that the project is in maintenance mode: the maintainers now recommend migrating to VectorChord, the successor extension.

API Design — Usage mirrors each host library’s idioms — a SQLAlchemy Vector column, a Psycopg 3 adapter with COPY support, or a Django field — so developers add vector search without learning a bespoke API. A standalone SDK client is also provided for direct use.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search