Skip to main content

list_partitions()

This operation lists the partitions in a specified collection.

Request syntax

list_partitions(
collection_name: str,
timeout: Optional[float] = None
) -> list

PARAMETERS:

  • collection_name (str) -

    [REQUIRED]

    The name of an existing collection.

  • timeout (float | None)

    The timeout duration for this operation. Setting this to None indicates that this operation timeouts when any response arrives or any error occurs.

RETURN TYPE:

list

RETURNS:

A list of partition names.

EXCEPTIONS:

  • MilvusException

    This exception will be raised when any error occurs during this operation.

Example

from pymilvus import MilvusClient

# 1. Create a milvus client
client = MilvusClient(
uri="https://inxx-xxxxxxxxxxxx.api.gcp-us-west1.zillizcloud.com:19530",
token="user:password"
)

# 2. Create a collection
client.create_collection(collection_name="test_collection", dimension=5)

# 3. Create a partition
client.create_partition(
collection_name="test_collection",
partition_name="partition_A"
)

# 4. List the names of all existing partitions
client.list_partitions(
collection_name="test_collection",
)

# ['_default', 'partition_A']