from pymilvus import (
    connections,
    utility,
    FieldSchema,
    CollectionSchema,
    DataType,
    Collection,
    MilvusClient,
    db,
    Function,
    FunctionType,
    AnnSearchRequest,
    WeightedRanker
)
import os
class Milvus_Database:
    def __init__(self,user=os.getenv("Milvus_USER","root"),password=os.getenv("Milvus_PASSWORD","Milvus"),uri=os.getenv("Milvus_URI")):
        self.client = MilvusClient(
        uri=uri,
        token=f"{user}:{password}"
    )
    def has_collection(self,collection_name,database_name):
            """
            Before using list collection, You need to using using_database method first
            """
            self.client.using_database(db_name=database_name)
            return self.client.has_collection(collection_name)
    
if __name__ == "__main__":
    db=Milvus_Database(uri="http://172.18.30.165:19530")
    print(db.has_collection("test","XIAN"))