¿What is the best practice for managing couchbase connections?

I have a project that uses the Couchbase python SDK.

And I recursively make connections to the cluster. My connection file is something like:

from couchbase.cluster import Cluster, ClusterOptions
#from couchbase_core.cluster import PasswordAuthenticator

from couchbase.auth import PasswordAuthenticator
# needed for options -- cluster, timeout, SQL++ (N1QL) query, etc.
from couchbase.options import (ClusterOptions)

def conexion():
    # especifique el clúster y especifique un autenticador que contenga un nombre de usuario 
    # y una contraseña para pasar al clúster.
    cluster = Cluster('couchbase://', ClusterOptions(PasswordAuthenticator('user', 'userPasw')))
    return cluster

I have several files with that connection code for each entity, for example: (room, window, services, offices, etc.), and I consult it by opening several connections to the database per query.

Is this practice well done?
Should I have a single connection file?
Should a single connection be opened for n number of queries?

Hi @Daniel_Pardo_Cuenca,

The recommended practice is to stick to a single connection for running multiple queries as there is a bit of overhead in creating the connections.

From the docs,

We recommend creating a single Cluster instance when your application starts up, and sharing this instance throughout your application. If you know at startup time which buckets, scopes, and collections your application will use, we recommend obtaining them from the Cluster at startup time and sharing those instances throughout your application as well.