-
Notifications
You must be signed in to change notification settings - Fork 339
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
enhance: add database operation example (#2516)
enhance: add database operation example issue :#2338 Signed-off-by: Xianhui.Lin <[email protected]>
- Loading branch information
Showing
1 changed file
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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()) |