Delete a collection and all its data using the DashVector Python SDK.
Prerequisites
Before you begin, make sure that you have:
A DashVector cluster
An API key
The DashVector SDK for Python (latest version)
API definition
Client.delete(name: str) -> DashVectorResponseRequest parameter
| Parameter | Type | Required | Description |
|---|---|---|---|
name | str | Yes | Name of the collection to delete |
Response
The method returns a DashVectorResponse object:
| Field | Type | Description | Example |
|---|---|---|---|
code | int | Status code. 0 indicates success. | 0 |
message | str | Response message | success |
request_id | str | Unique request ID for troubleshooting | 19215409-ea66-4db9-8764-26ce2eb5bb99 |
Example
Important
Deleting a collection permanently removes all its data. This action cannot be undone.
Replace the following placeholders before running the code:
| Placeholder | Description |
|---|---|
<your-api-key> | Your DashVector API key |
<your-cluster-endpoint> | Your cluster endpoint |
import dashvector
# Initialize the client
client = dashvector.Client(
api_key='<your-api-key>',
endpoint='<your-cluster-endpoint>'
)
# Delete the collection and all its data
resp = client.delete(name='quickstart')
print(resp)Expected output on success:
code: 0
message: success
request_id: 19215409-ea66-4db9-8764-26ce2eb5bb99Note
This example deletes a collection named quickstart. To create this collection, see the "Example" section of Create a collection.
What's next
Create a collection -- Create a new collection to store vectors
Status codes -- Troubleshoot errors using the status code reference