logo
Browse Source

Support uri and token

Signed-off-by: Kaiyuan.Hu <kaiyuan.hu@zilliz.com>
main
Kaiyuan.Hu 2 years ago
parent
commit
201a4b781f
  1. 13
      milvus_client.py

13
milvus_client.py

@ -26,19 +26,24 @@ class MilvusClient(PyOperator):
"""
def __init__(self, host: str = 'localhost', port: int = 19530, collection_name: str = None,
user: str = None, password: str = None, **kwargs):
uri: str = None, user: str = None, password: str = None, token: str = None, **kwargs):
"""
Get an existing collection.
"""
self._host = host
self._port = port
self._uri = uri
self._collection_name = collection_name
self._connect_name = uuid.uuid4().hex
if None in [user, password]:
connections.connect(alias=self._connect_name, host=self._host, port=self._port)
else:
if uri and token:
connections.connect(alias=self._connect_name, uri=self._uri, token=token, secure=True)
elif user and password:
connections.connect(alias=self._connect_name, host=self._host, port=self._port,
user=user, password=password, secure=True)
else:
connections.connect(alias=self._connect_name, host=self._host, port=self._port)
self._collection = Collection(self._collection_name, using=self._connect_name)
self.kwargs = kwargs

Loading…
Cancel
Save