Closed dynamicdeploy closed 1 month ago
I am getting this now. Installed pgvector and psycopg3
Mac OS psycopg 3.2.2 vector extensions is enabled and works from pgAdmin in Postgres
This is the code. I haven't gotten anything to work so far.
import psycopg import numpy as np from pgvector.psycopg import register_vector
with psycopg.connect("postgresql://xxx:xxx$@localhost:5432/xxx") as conn:
conn.execute('CREATE EXTENSION IF NOT EXISTS vector') register_vector(conn) conn.execute('CREATE TABLE items (id bigserial PRIMARY KEY, embedding vector(3))') # https://github.com/pgvector/pgvector-python/issues/4 <-- tried everything from here. embedding = np.array([1, 2, 3]) conn.execute('INSERT INTO items (embedding) VALUES (%s)', (embedding,)) conn.execute('SELECT * FROM items ORDER BY embedding <-> %s LIMIT 5', (embedding,)).fetchall()
Hi @dynamicdeploy, see https://github.com/pgvector/pgvector-python/issues/91#issuecomment-2379693632.
I am getting this now. Installed pgvector and psycopg3
Mac OS psycopg 3.2.2 vector extensions is enabled and works from pgAdmin in Postgres
This is the code. I haven't gotten anything to work so far.
import psycopg import numpy as np from pgvector.psycopg import register_vector
with psycopg.connect("postgresql://xxx:xxx$@localhost:5432/xxx") as conn: