1818 sqlalchemy_version = 1
1919
2020psycopg2_engine = create_engine ('postgresql+psycopg2://localhost/pgvector_python_test' )
21- pg8000_engine = create_engine (f'postgresql+pg8000://{ os .environ ["USER" ]} @localhost/pgvector_python_test' )
2221psycopg2_type_engine = create_engine ('postgresql+psycopg2://localhost/pgvector_python_test' )
2322
2423
@@ -28,51 +27,44 @@ def psycopg2_connect(dbapi_connection, connection_record):
2827 register_vector (dbapi_connection , globally = False , arrays = True )
2928
3029
31- engines = [psycopg2_engine , pg8000_engine , psycopg2_type_engine ]
32- array_engines = [psycopg2_type_engine ]
33- async_engines = []
34- async_array_engines = []
30+ pg8000_engine = create_engine (f'postgresql+pg8000://{ os .environ ["USER" ]} @localhost/pgvector_python_test' )
3531
3632if sqlalchemy_version > 1 :
3733 psycopg_engine = create_engine ('postgresql+psycopg://localhost/pgvector_python_test' )
38- engines .append (psycopg_engine )
39-
4034 psycopg_type_engine = create_engine ('postgresql+psycopg://localhost/pgvector_python_test' )
4135
4236 @event .listens_for (psycopg_type_engine , "connect" )
4337 def psycopg_connect (dbapi_connection , connection_record ):
4438 from pgvector .psycopg import register_vector
4539 register_vector (dbapi_connection )
4640
47- engines .append (psycopg_type_engine )
48- array_engines .append (psycopg_type_engine )
49-
41+ psycopg_async_engine = create_async_engine ('postgresql+psycopg://localhost/pgvector_python_test' )
5042 psycopg_async_type_engine = create_async_engine ('postgresql+psycopg://localhost/pgvector_python_test' )
5143
5244 @event .listens_for (psycopg_async_type_engine .sync_engine , "connect" )
5345 def connect (dbapi_connection , connection_record ):
5446 from pgvector .psycopg import register_vector_async
5547 dbapi_connection .run_async (register_vector_async )
5648
57- async_engines .append (psycopg_async_type_engine )
58- async_array_engines .append (psycopg_async_type_engine )
59-
60- psycopg_async_engine = create_async_engine ('postgresql+psycopg://localhost/pgvector_python_test' )
61- async_engines .append (psycopg_async_engine )
62-
6349 asyncpg_engine = create_async_engine ('postgresql+asyncpg://localhost/pgvector_python_test' )
64- async_engines .append (asyncpg_engine )
65- async_array_engines .append (asyncpg_engine )
66-
6750 asyncpg_type_engine = create_async_engine ('postgresql+asyncpg://localhost/pgvector_python_test' )
6851
6952 @event .listens_for (asyncpg_type_engine .sync_engine , "connect" )
7053 def connect (dbapi_connection , connection_record ):
7154 from pgvector .asyncpg import register_vector
7255 dbapi_connection .run_async (register_vector )
7356
74- # TODO do not throw error when types are registered
75- # async_array_engines.append(asyncpg_type_engine)
57+ engines = [psycopg2_engine , psycopg2_type_engine , pg8000_engine ]
58+ array_engines = [psycopg2_type_engine ]
59+ async_engines = []
60+ async_array_engines = []
61+
62+ if sqlalchemy_version > 1 :
63+ engines += [psycopg_engine , psycopg_type_engine ]
64+ array_engines += [psycopg_type_engine ]
65+ async_engines += [psycopg_async_engine , psycopg_async_type_engine , asyncpg_engine ]
66+ # TODO add asyncpg_type_engine
67+ async_array_engines += [psycopg_async_type_engine , asyncpg_engine ]
7668
7769setup_engine = engines [0 ]
7870with Session (setup_engine ) as session :
0 commit comments