{"id":21688,"library":"pgvecto-rs","title":"pgvecto-rs Python Binding","description":"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.","status":"active","version":"0.2.2","language":"python","source_language":"en","source_url":"https://github.com/tensorchord/pgvecto.rs","tags":["vector-database","postgresql","embeddings","pgvector","similarity-search"],"install":[{"cmd":"pip install pgvecto-rs","lang":"bash","label":"Install from PyPI"}],"dependencies":[{"reason":"ORM support for vector columns","package":"sqlalchemy","optional":true}],"imports":[{"note":"Hyphen in package name; underscore in import","wrong":"import pgvecto-rs","symbol":"client","correct":"from pgvecto_rs import client"},{"note":"Must import from submodule sqlalchemy","wrong":"from pgvecto_rs import SQLModelVector","symbol":"SQLModelVector","correct":"from pgvecto_rs.sqlalchemy import SQLModelVector"},{"note":"Vector type lives in sqlalchemy submodule","wrong":"from pgvecto_rs import Vector","symbol":"Vector","correct":"from pgvecto_rs.sqlalchemy import Vector"}],"quickstart":{"code":"from pgvecto_rs import client\n\nconn = client.connect(\n    host='localhost',\n    port=5432,\n    user='postgres',\n    password=os.environ.get('PGPASSWORD', ''),\n    database='vectordb'\n)\nconn.execute(\"CREATE EXTENSION IF NOT EXISTS vectors\")\nconn.execute(\"CREATE TABLE IF NOT EXISTS items (id bigserial PRIMARY KEY, embedding vector(3))\")\nconn.execute(\"INSERT INTO items (embedding) VALUES ('[1,2,3]'::vector)\")\nresults = conn.execute(\"SELECT * FROM items ORDER BY embedding <-> '[3,2,1]'::vector LIMIT 5\")\nfor row in results:\n    print(row)","lang":"python","description":"Connect to PostgreSQL, enable pgvecto.rs extension, create a vector table, insert and query vectors."},"warnings":[{"fix":"Use client.connect(...) with parameters, not raw psycopg2 connections.","message":"The 'pgvecto_rs.client' module uses a different connection API than psycopg2. Do not use psycopg2 connection objects directly; use client.connect().","severity":"breaking","affected_versions":"all"},{"fix":"Cast vectors to string: str([1,2,3]) or use f\"'{list}'::vector\".","message":"Vector dimensions must match column definition when inserting. Use string representation like '[1,2,3]'::vector. Lists or numpy arrays are not directly accepted.","severity":"gotcha","affected_versions":"all"},{"fix":"Check the official documentation for supported features. For connection pooling, use SQLAlchemy or another pooling library.","message":"The '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.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Run 'pip install pgvecto-rs' and import as 'pgvecto_rs' (underscore).","cause":"Package name has hyphen but import uses underscore; also may not be installed.","error":"ModuleNotFoundError: No module named 'pgvecto_rs'"},{"fix":"Use 'from pgvecto_rs.sqlalchemy import SQLModelVector'.","cause":"SQLModelVector is in submodule pgvecto_rs.sqlalchemy.","error":"AttributeError: module 'pgvecto_rs' has no attribute 'SQLModelVector'"},{"fix":"Install pgvecto.rs on the server (see docs). Then run 'CREATE EXTENSION vectors' as superuser.","cause":"pgvecto.rs extension not installed on the PostgreSQL server, or shared library path not set.","error":"psycopg2.errors.UndefinedFile: extension \"vectors\" is not available"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}