From 2cd4ffb934e861b809a1de193f915a75b3c16ed1 Mon Sep 17 00:00:00 2001 From: "Xianhui.Lin" Date: Thu, 26 Dec 2024 19:19:00 +0800 Subject: [PATCH] add database operation example Signed-off-by: Xianhui.Lin --- examples/database.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 examples/database.py diff --git a/examples/database.py b/examples/database.py new file mode 100644 index 000000000..d9d5f45a7 --- /dev/null +++ b/examples/database.py @@ -0,0 +1,33 @@ +import numpy as np +from pymilvus import ( + MilvusClient, + DataType +) + +milvus_client = MilvusClient("http://localhost:19530") + +db1Name = "db1" +# create db1 +if db1Name not in milvus_client.list_databases(): + print("\ncreate database: db1") + milvus_client.create_database(db_name=db1Name, properties={"key1":"value1"}) + db_info = milvus_client.describe_database(db_name=db1Name) + print(db_info) + + +# alter_database_properties of db1 +db_info = milvus_client.describe_database(db_name=db1Name) +print(db_info) +print("\nalter database properties of db1:") +milvus_client.alter_database_properties(db_name=db1Name, properties={"key": "value"}) +db_info = milvus_client.describe_database(db_name=db1Name) +print(db_info) + +print("\ndrop database properties of db1") +milvus_client.drop_database_properties(db_name=db1Name, property_keys=["key"]) +db_info = milvus_client.describe_database(db_name=db1Name) +print(db_info) + +# list database +print("\nlist databases:") +print(milvus_client.list_databases()) \ No newline at end of file