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

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="http://localhost:19530")

# Switch to a different database
client.use_database(db_name="my_database")

# Subsequent operations will use "my_database"
collections = client.list_collections()

Try Managed Milvus for Free

Zilliz Cloud is hassle-free, powered by Milvus and 10x faster.

Get Started
Feedback

Was this page helpful?