From 9abfa4d25b56e12239dc481f3d3aa2868f6f4eac Mon Sep 17 00:00:00 2001 From: linyuansup Date: Thu, 10 Sep 2026 08:07:08 +0000 Subject: [PATCH 1/2] Fix the sample code to use the connection context manager and update the definition of the vector column --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 26dccfb..73ffe74 100644 --- a/README.md +++ b/README.md @@ -353,7 +353,8 @@ def connect(dbapi_connection, connection_record): Enable the extension ```python -session.exec(text('CREATE EXTENSION IF NOT EXISTS vector')) +with engine.begin() as conn: + conn.execute(text("CREATE EXTENSION IF NOT EXISTS vector")) ``` Add a vector column @@ -362,7 +363,7 @@ Add a vector column from pgvector.sqlalchemy import VECTOR class Item(SQLModel, table=True): - embedding: list[float] = Field(sa_type=VECTOR(3)) + embedding: list[float] = Field(sa_column=Column(VECTOR(3))) ``` Also supports `HALFVEC`, `BIT`, and `SPARSEVEC` From c724dc5af2686b0fe83be03b609798253baabd7e Mon Sep 17 00:00:00 2001 From: linyuansup Date: Thu, 10 Sep 2026 08:16:45 +0000 Subject: [PATCH 2/2] Add Column Import --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 73ffe74..a42fb6b 100644 --- a/README.md +++ b/README.md @@ -361,6 +361,7 @@ Add a vector column ```python from pgvector.sqlalchemy import VECTOR +from sqlalchemy import Column class Item(SQLModel, table=True): embedding: list[float] = Field(sa_column=Column(VECTOR(3)))