如果透過python的sdk pymilvus 判斷一個 collection 是否存在?

ponponon 發表於 2022-11-30
Python

刪除集合

方案一:

def delete_collection():
    from pymilvus import utility
    utility.drop_collection(settings.MILVUS_CONFIG.collection.name)

方案二:

from core.milvus.models import collection

conn = connections._fetch_handler('default')

if conn.has_collection(settings.MILVUS_CONFIG.collection.name):
    logger.debug('集合已存在')
    collection.drop()