Dropping a collection permanently deletes the collection and everything stored in it (vectors, metadata fields, indexes, partitions). This action is irreversible.
Be careful: If you need the data later, export/backup it before you drop the collection.
Drop a collection
Use drop_collection() to remove a collection by name.
from dodil import Client
from dodil.vbase import VBaseConfig
# Authorize using your Service Account
c = Client(
service_account_id="...",
service_account_secret="...",
)
# Connect to your VBase database
vbase = c.vbase.connect(
VBaseConfig(
host="vbase-db-<id>.infra.dodil.cloud",
port=443,
scheme="https",
db_name="db_<id>",
)
)
collection_name = "my_collection"
# (Optional) guard: check it exists first
if not vbase.has_collection(collection_name):
raise RuntimeError(f"Collection '{collection_name}' does not exist")
# Drop the collection (irreversible)
vbase.drop_collection(collection_name)
print("Dropped:", collection_name)Verify it was removed
After dropping, you can list collections (or check existence) to confirm.
print(vbase.list_collections())
print("exists?", vbase.has_collection("my_collection"))Notes and best practices
- Irreversible: Dropping deletes data and indexes. If you need to keep the data, export or copy it to another collection first.
- Active workloads: If your application is actively querying/searching the collection, you may see transient errors until clients refresh. Consider pausing traffic before dropping.
- Loaded collections: If the collection is currently loaded in memory, dropping it still removes the collection, but it’s a good operational habit to release it first in busy environments:
vbase.release_collection("my_collection")
vbase.drop_collection("my_collection")- Permissions: Your Service Account must have permission to manage collections for the target database.
Last updated on