Skip to content

Commit b95d4a8

Browse files
committed
Improved examples [skip ci]
1 parent 60fc9c6 commit b95d4a8

2 files changed

Lines changed: 3 additions & 5 deletions

File tree

examples/pytorch_image_search.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@
1010

1111

1212
# establish connection
13-
conn = psycopg.connect(dbname='pgvector_example')
14-
conn.autocommit = True
13+
conn = psycopg.connect(dbname='pgvector_example', autocommit=True)
1514
conn.execute('CREATE EXTENSION IF NOT EXISTS vector')
1615
register_vector(conn)
1716

@@ -38,7 +37,7 @@ def generate_embeddings(inputs):
3837
# generate, save, and index embeddings
3938
if seed:
4039
conn.execute('DROP TABLE IF EXISTS image')
41-
conn.execute('CREATE TABLE image (id bigserial primary key, embedding vector(512))')
40+
conn.execute('CREATE TABLE image (id bigserial PRIMARY KEY, embedding vector(512))')
4241

4342
for data in tqdm(dataloader):
4443
embeddings = generate_embeddings(data[0])

tests/test_psycopg.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
import psycopg
44
import pytest
55

6-
conn = psycopg.connect(dbname='pgvector_python_test')
7-
conn.autocommit = True
6+
conn = psycopg.connect(dbname='pgvector_python_test', autocommit=True)
87

98
conn.execute('CREATE EXTENSION IF NOT EXISTS vector')
109
conn.execute('DROP TABLE IF EXISTS item')

0 commit comments

Comments
 (0)