add_connection()
This operation adds connections to multiple Zilliz Cloud clusters for different purposes in a batch.
Request Syntax
add_connection(
default: dict,
# add other connections
# your_conn_name: dict
)
PARAMETERS:
-
kwargs -
When passing keyword arguments, the name of each argument will serve as a connection alias in the connect() method.
The argument value should be a dictionary with one or more of these fields:
-
address (string) -
The actual address to connect. Example address: localhost:19530.
-
uri (string) -
The URI of the Zilliz Cloud cluster. For example: https://in01-*****************.aws-us-west-2.vectordb-uat3.zillizcloud.com:19540.
-
host (string) -
The host of the Zilliz Cloud cluster. The value defaults to localhost, and PyMilvus will fill in the default host if only port is provided.
-
port (string | int) -
The port that Zilliz Cloud cluster listens to. The value defaults to 19530, and PyMilvus will fill in the default port if only host is provided.
-
user (string) -
A valid username used to connect to the specified Zilliz Cloud cluster.
This should be used along with password.
-
password (string) -
A valid password used to connect to the specified Zilliz Cloud cluster.
This should be used along with user.
-
token (string) -
A valid access token to access the specified Zilliz Cloud cluster. This can be used as an alternative to setting user and password separately.
When setting this field, notice that:
A valid token should be either
-
An API key with sufficient permissions, or
-
A pair of username and password used to access the target cluster, joined by a colon (:). For example, you can set this to
username:p@ssw0rd
.
-
-
- Cluster endpoint
You can log into the Zilliz Cloud console and click Clusters in the left navigation pane. In the cluster list, click the name of the target cluster, copy its endpoint in the Connect area, and use it as the URI above.
- Access token
To connect to a Zilliz Cloud cluster, you can use either of the following
- An API key
You can log into the Zilliz Cloud console and click API Keys in the left navigation pane.
- A pair of username and password to access the cluster, joined by a colon (:).
You can use the cluster credentials specified when the cluster has been created on the Zilliz Cloud console, or those of any existing cluster users.
For details, refer to On Zilliz Cloud Console for more information.
RETURN TYPE:
None
RETURNS:
None
EXCEPTIONS:
-
ConnectionConfigException
This exception will be raised when the connection configuration is invalid.
Examples
from pymilvus import connections
SERVERLESS_ENDPOINT = "https://in03-************.api.gcp-us-west1.zillizcloud.com"
SERVERLESS_TOKEN = "db_admin:************"
DEDICATED_ENDPOINT = "https://in03-************.api.gcp-us-west1.zillizcloud.com:19541"
DEDICATED_USER = "db_admin"
DEDICATED_PASS = "*****************"
connections.add_connection(
serverless={"uri": SERVERLESS_ENDPOINT, "token": SERVERLESS_TOKEN},
dedicated={"uri": DEDICATED_ENDPOINT, "user": DEDICATED_USER, "password": DEDICATED_PASS}
)
Related operations
The following operations are related to add_connection()
: