diff --git a/pymilvus/client/grpc_handler.py b/pymilvus/client/grpc_handler.py index 30b59648e..78b9980ff 100644 --- a/pymilvus/client/grpc_handler.py +++ b/pymilvus/client/grpc_handler.py @@ -1399,7 +1399,7 @@ def describe_database(self, db_name: str, timeout: Optional[float] = None): request = Prepare.describe_database_req(db_name=db_name) resp = self._stub.DescribeDatabase(request, timeout=timeout) check_status(resp.status) - return DatabaseInfo(resp).properties + return DatabaseInfo(resp).to_dict() @retry_on_rpc_failure() def get_load_state( diff --git a/pymilvus/client/types.py b/pymilvus/client/types.py index 3e9aa3909..838c4e1d9 100644 --- a/pymilvus/client/types.py +++ b/pymilvus/client/types.py @@ -1013,3 +1013,35 @@ def get_cost_extra(status: Optional[common_pb2.Status] = None): # Construct extra dict, the cost unit is the vcu, similar to tokenlike the def construct_cost_extra(cost: int): return {"cost": cost} + +class DatabaseInfo: + """ + Represents the information of a database. + Atributes: + name (str): The name of the database. + properties (dict): The properties of the database. + Example: + DatabaseInfo(name="test_db", id=1, properties={"key": "value"}) + """ + + @property + def name(self) -> str: + return self._name + + @property + def properties(self) -> Dict: + return self._properties + + def __init__(self, info: Any) -> None: + self._name = info.db_name + self._properties = {} + + for p in info.properties: + self.properties[p.key] = p.value + + def __str__(self) -> str: + return f"DatabaseInfo(name={self.name}, properties={self.properties})" + + def to_dict(self) -> Dict[str, Any]: + """Converts the DatabaseInfo instance to a dictionary.""" + return {"name": self.name, "properties": self.properties}