feat: - vector

This commit is contained in:
heyong.fu
2026-05-06 11:29:40 +08:00
commit bffbdb9046
43 changed files with 17172 additions and 0 deletions
+30
View File
@@ -0,0 +1,30 @@
# 通过pymilvus sdk来操作数据库
from pymilvus import connections, utility
def test_connection(
host: str = "49.233.56.55", port: str = "19530", db_name: str = "default"
) -> bool:
try:
# 建立与milvus的连接
connections.connect(
"default", host=host, port=port, timeout=10, db_name=db_name
)
# 打印当前连接到的数据库名称
print(f"当前连接到的数据库为: {db_name}")
# 获取搜友集合并打印
collections = utility.list_collections()
print(f"数据库{db_name}下的所有数据集合{collections}")
# 连接成功提示
print("连接成功:已成功连接到 Milvus 服务器")
return True
except Exception as exc:
print(f"连接失败,无法连接到Milvus服务器的数据库{db_name}", exc)
return False
if __name__ == "__main__":
if not test_connection():
raise SystemExit(1)