Skip to content

Does PGVector really need SQLAlchemy URLs? If so, why not psycopg3? #214

Open
@khteh

Description

@khteh

When I use postgresql scheme, I hit this error:

  File "/usr/src/Python/rag-agent/src/Infrastructure/VectorStore.py", line 87, in __init__
    self.vector_store = PGVector(
                        ~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        embeddings = self._embeddings,
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ...<3 lines>...
        async_mode = True
        ^^^^^^^^^^^^^^^^^
    )
    ^
  File "/home/khteh/.local/share/virtualenvs/rag-agent-YeW3dxEa/lib/python3.13/site-packages/langchain_postgres/vectorstores.py", line 434, in __init__
    self._async_engine = create_async_engine(
                         ~~~~~~~~~~~~~~~~~~~^
        connection, **(engine_args or {})
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/home/khteh/.local/share/virtualenvs/rag-agent-YeW3dxEa/lib/python3.13/site-packages/sqlalchemy/ext/asyncio/engine.py", line 120, in create_async_engine
    sync_engine = _create_engine(url, **kw)
  File "<string>", line 2, in create_engine
  File "/home/khteh/.local/share/virtualenvs/rag-agent-YeW3dxEa/lib/python3.13/site-packages/sqlalchemy/util/deprecations.py", line 281, in warned
    return fn(*args, **kwargs)  # type: ignore[no-any-return]
  File "/home/khteh/.local/share/virtualenvs/rag-agent-YeW3dxEa/lib/python3.13/site-packages/sqlalchemy/engine/create.py", line 602, in create_engine
    dbapi = dbapi_meth(**dbapi_args)
  File "/home/khteh/.local/share/virtualenvs/rag-agent-YeW3dxEa/lib/python3.13/site-packages/sqlalchemy/dialects/postgresql/psycopg2.py", line 696, in import_dbapi
    import psycopg2
ModuleNotFoundError: No module named 'psycopg2'

(1) Why psycopg2 instead of psycopg3 (https://www.psycopg.org/psycopg3/docs/basic/install.html)?

(2) Does it actually need SQLAlchemy URLs since it is PGVector? Why not directly using the postgresql scheme?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions