66conn = psycopg .connect (dbname = 'pgvector_python_test' , autocommit = True )
77
88conn .execute ('CREATE EXTENSION IF NOT EXISTS vector' )
9- conn .execute ('DROP TABLE IF EXISTS item ' )
10- conn .execute ('CREATE TABLE item (id bigserial PRIMARY KEY, embedding vector(3))' )
9+ conn .execute ('DROP TABLE IF EXISTS items ' )
10+ conn .execute ('CREATE TABLE items (id bigserial PRIMARY KEY, embedding vector(3))' )
1111
1212register_vector (conn )
1313
1414
1515class TestPsycopg :
1616 def setup_method (self , test_method ):
17- conn .execute ('DELETE FROM item ' )
17+ conn .execute ('DELETE FROM items ' )
1818
1919 def test_works (self ):
2020 embedding = np .array ([1.5 , 2 , 3 ])
21- conn .execute ('INSERT INTO item (embedding) VALUES (%s), (NULL)' , (embedding ,))
21+ conn .execute ('INSERT INTO items (embedding) VALUES (%s), (NULL)' , (embedding ,))
2222
23- res = conn .execute ('SELECT * FROM item ORDER BY id' ).fetchall ()
23+ res = conn .execute ('SELECT * FROM items ORDER BY id' ).fetchall ()
2424 assert np .array_equal (res [0 ][1 ], embedding )
2525 assert res [0 ][1 ].dtype == np .float32
2626 assert res [1 ][1 ] is None
@@ -55,19 +55,19 @@ def test_binary_format_non_contiguous(self):
5555 def test_text_copy (self ):
5656 embedding = np .array ([1.5 , 2 , 3 ])
5757 cur = conn .cursor ()
58- with cur .copy ("COPY item (embedding) FROM STDIN" ) as copy :
58+ with cur .copy ("COPY items (embedding) FROM STDIN" ) as copy :
5959 copy .write_row ([embedding ])
6060
6161 def test_binary_copy (self ):
6262 embedding = np .array ([1.5 , 2 , 3 ])
6363 cur = conn .cursor ()
64- with cur .copy ("COPY item (embedding) FROM STDIN WITH (FORMAT BINARY)" ) as copy :
64+ with cur .copy ("COPY items (embedding) FROM STDIN WITH (FORMAT BINARY)" ) as copy :
6565 copy .write_row ([embedding ])
6666
6767 def test_binary_copy_set_types (self ):
6868 embedding = np .array ([1.5 , 2 , 3 ])
6969 cur = conn .cursor ()
70- with cur .copy ("COPY item (id, embedding) FROM STDIN WITH (FORMAT BINARY)" ) as copy :
70+ with cur .copy ("COPY items (id, embedding) FROM STDIN WITH (FORMAT BINARY)" ) as copy :
7171 copy .set_types (['int8' , 'vector' ])
7272 copy .write_row ([1 , embedding ])
7373
@@ -76,16 +76,16 @@ async def test_async(self):
7676 conn = await psycopg .AsyncConnection .connect (dbname = 'pgvector_python_test' , autocommit = True )
7777
7878 await conn .execute ('CREATE EXTENSION IF NOT EXISTS vector' )
79- await conn .execute ('DROP TABLE IF EXISTS item ' )
80- await conn .execute ('CREATE TABLE item (id bigserial PRIMARY KEY, embedding vector(3))' )
79+ await conn .execute ('DROP TABLE IF EXISTS items ' )
80+ await conn .execute ('CREATE TABLE items (id bigserial PRIMARY KEY, embedding vector(3))' )
8181
8282 await register_vector_async (conn )
8383
8484 embedding = np .array ([1.5 , 2 , 3 ])
85- await conn .execute ('INSERT INTO item (embedding) VALUES (%s), (NULL)' , (embedding ,))
85+ await conn .execute ('INSERT INTO items (embedding) VALUES (%s), (NULL)' , (embedding ,))
8686
8787 async with conn .cursor () as cur :
88- await cur .execute ('SELECT * FROM item ORDER BY id' )
88+ await cur .execute ('SELECT * FROM items ORDER BY id' )
8989 res = await cur .fetchall ()
9090 assert np .array_equal (res [0 ][1 ], embedding )
9191 assert res [0 ][1 ].dtype == np .float32
0 commit comments