Registry / vector-search / pgvecto-rs

pgvecto-rs

JSON →
library0.2.2pypypi✓ verified 83d ago

Python binding for pgvecto.rs, a vector similarity search extension for PostgreSQL. Current version 0.2.2, requires Python 3.8-3.12. Provides client and ORM integrations for vector operations in PostgreSQL.

pip install pgvecto-rs
INSTALL
IMPORT
SIG · PGVECTO-RS
P
pgvecto-rs
vector-searchpythonv0.2.2
Install
3.7s avg
Import
Disk
89MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.2.2 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 89.8MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 3.7s · import 0.000s · 86MB
89MB installed
● package 89MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

client
import pgvecto_rs
from pgvecto_rs import client

Connect to PostgreSQL, enable pgvecto.rs extension, create a vector table, insert and query vectors.

from pgvecto_rs import client conn = client.connect( host='localhost', port=5432, user='postgres', password=os.environ.get('PGPASSWORD', ''), database='vectordb' ) conn.execute("CREATE EXTENSION IF NOT EXISTS vectors") conn.execute("CREATE TABLE IF NOT EXISTS items (id bigserial PRIMARY KEY, embedding vector(3))") conn.execute("INSERT INTO items (embedding) VALUES ('[1,2,3]'::vector)") results = conn.execute("SELECT * FROM items ORDER BY embedding <-> '[3,2,1]'::vector LIMIT 5") for row in results: print(row)
Debug
Known issues
breakingThe 'pgvecto_rs.client' module uses a different connection API than psycopg2. Do not use psycopg2 connection objects directly; use client.connect().
fix
Use client.connect(...) with parameters, not raw psycopg2 connections.
affects: all
gotchaVector dimensions must match column definition when inserting. Use string representation like '[1,2,3]'::vector. Lists or numpy arrays are not directly accepted.
fix
Cast vectors to string: str([1,2,3]) or use f"'{list}'::vector".
affects: all
gotchaThe 'client' module is not a drop-in replacement for 'psycopg2'. It wraps a different underlying driver (Rust-based). Some psycopg2 features (e.g., connection pooling, async) may not be available.
fix
Check the official documentation for supported features. For connection pooling, use SQLAlchemy or another pooling library.
affects: all
Upgrade
Version history
0.2.2latest on PyPI · released Oct 8, 2024
Audit
Dependencies
sqlalchemyoptionalORM support for vector columns
Agent activity
44 hits · last 30 days
node
36
OpenAI (training)
1
Resources
pgvecto-rs — pip install pgvecto-rs · libregistry