# python chromadb_clear.py "e:/chromadb/dbname" "collection_name"
import sys
import chromadb
import json
from chromadb.config import Settings

argvlen = len(sys.argv)
if argvlen == 3:
    localdbpaht = sys.argv[1]
    collectionname = sys.argv[2]
	
	# 设置本地数据库名称（Persistent本地持久化）和表名（Collection集合）
    CHROMA_CLIENT = chromadb.PersistentClient(
        path = localdbpaht,
        settings = chromadb.Settings(anonymized_telemetry=False)
    )
    COLLECTION = CHROMA_CLIENT.get_or_create_collection(collectionname)
    # 清空集合
    COLLECTION.delete(ids=COLLECTION.get()["ids"])
	# 删除整个集合
    #CHROMA_CLIENT.delete_collection(name=collectionname)
else:
    print("python chromadb_clear.py \"e:/chromadb/dbname\" \"collection_name\"")          

# python chromadb_clear.py "e:/chromadb/dbname" "collection_name"