Skip to content

Commit

Permalink
enhance: [2.4]add database operation example (#2518)
Browse files Browse the repository at this point in the history
add database operation example
issue :#2338
master pr: #2516

Signed-off-by: Xianhui.Lin <[email protected]>
  • Loading branch information
JsDove authored Dec 26, 2024
1 parent 407c9e6 commit 1003372
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions examples/database.py
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())

0 comments on commit 1003372

Please sign in to comment.