Skip to main content

use_database()

Addedv2.6.x

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.

📘Notes

This is an alias method for using_database().

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()