[Python] Connection pool for beanie?

Discussão em 'Python' iniciado por Stack, Março 3, 2025.

  1. Stack

    Stack Membro Participativo

    I have the following function in my code:

    async def context(client_id: str)
    database = f'db_{client_id}'
    await init_beanie(
    database=database,
    document_models=[
    .. # quite a few models
    ],
    )


    Every time I fetch something from the database I will execute above function (it could be a different client every time).

    I don't know exactly what init_beanie does, but it seems there is an overhead calling it every time.

    I looked through the docs and couldn't find something like a connection pool or similar. Does such thing exist or is it not necessary?

    Continue reading...

Compartilhe esta Página