Skip to content

Commit dbc44f4

Browse files
committed
Added more examples for arrays with SQLAlchemy [skip ci]
1 parent 04aa5bc commit dbc44f4

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,30 @@ class Item(Base):
282282

283283
And register the types with the underlying driver
284284

285+
For Psycopg 3, use
286+
287+
```python
288+
from pgvector.psycopg import register_vector
289+
from sqlalchemy import event
290+
291+
@event.listens_for(engine, "connect")
292+
def connect(dbapi_connection, connection_record):
293+
register_vector(dbapi_connection)
294+
```
295+
296+
For [async connections](https://docs.sqlalchemy.org/en/20/orm/extensions/asyncio.html) with Psycopg 3, use
297+
298+
```python
299+
from pgvector.psycopg import register_vector_async
300+
from sqlalchemy import event
301+
302+
@event.listens_for(engine.sync_engine, "connect")
303+
def connect(dbapi_connection, connection_record):
304+
dbapi_connection.run_async(register_vector_async)
305+
```
306+
307+
For Psycopg 2, use
308+
285309
```python
286310
from pgvector.psycopg2 import register_vector
287311
from sqlalchemy import event

0 commit comments

Comments
 (0)