use_database()
This operation switches the client to use a different database. Future operations will use the specified database. The method validates that the database exists before switching.
This is an alias method for using_database().
This method applies only to dedicated serving clusters and on-demand compute.
For a database in dedicated serving clusters, please create MilvusClient with the cluster endpoint.
Free & Serverless
https://{cluster-id}.serverless.{region}.vectordb.zillizcloud.com
- Dedicated
https://{cluster-id}.{region}.vectordb.zillizcloud.com:19530
- For a database for on-demand compute, create MilvusClient with the project endpoints.
https://{project-id}.{region}.api.zillizcloud.com
Request syntax
client.use_database(
db_name: str
)
PARAMETERS:
-
db_name (str) -
[REQUIRED]
The name of the database to switch to.
RETURN TYPE:
NoneType
EXCEPTIONS:
-
MilvusException
This exception will be raised when the database does not exist (error code 800).
Example
from pymilvus import MilvusClient
client = MilvusClient(uri="YOUR_CLUSTER_ENDPOINT")
# Switch to a different database
client.use_database(db_name="my_database")
# Subsequent operations will use "my_database"
collections = client.list_collections()