Coder Social home page Coder Social logo

Comments (6)

ankane avatar ankane commented on August 30, 2024 1

If it's not persisting, then yes. I'd recommend connecting to your database with psql to check:

SELECT extversion FROM pg_extension WHERE extname = 'vector';

from pgvector-python.

dmvieira avatar dmvieira commented on August 30, 2024

I did here a workaround that solved errors and keep a single pool. Start pool in __new__ once for solving second one:

   def __new__(cls):
        # Adding Singleton for only one connection and database configuration
        with cls._lock:
            if cls._instance is None:
                cls._pool = ConnectionPool(
                    kwargs=pgvectorstore_config(),
                    max_size=20,
                    check=ConnectionPool.check_connection,
                    configure=cls.register_pgvector,
                    open=True
                )
                cls._instance = super().__new__(cls)
        return cls._instance

Add lock inside register_vector, solving multi worker configuration (first error):

def register_pgvector(cls, conn: Connection):
    with cls._lock():
        stmt = 'CREATE EXTENSION IF NOT EXISTS vector'
        with conn.cursor() as cur:
            cur.execute(stmt)
        register_vector(conn)

from pgvector-python.

ankane avatar ankane commented on August 30, 2024

Hi @dmvieira, I'd recommend running CREATE EXTENSION with your schema / migration code rather than on every connection.

from pgvector-python.

dmvieira avatar dmvieira commented on August 30, 2024

Hey @ankane , for some reason it requires every new connection too. It throws an exception:

error connecting in 'pool-1': vector type not found in the database

from pgvector-python.

ankane avatar ankane commented on August 30, 2024

Make sure you're committing the transaction.

https://www.psycopg.org/psycopg3/docs/basic/transactions.html

from pgvector-python.

dmvieira avatar dmvieira commented on August 30, 2024

It's already configured with autocommit 🤔 ... it's really necessary?

from pgvector-python.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.