You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

GridDB Python客户端调用get_store()遇notification_address参数错误求助

问题

在Ubuntu 22.04系统上使用GridDB,已安装griddb-python客户端,运行连接代码时出现以下错误:

Traceback (most recent call last):
  File "/home/panda/dev/python/create_db.py", line 13, in <module>
    store = factory.get_store(
TypeError: StoreFactory.get_store() got an unexpected keyword argument 'notification_address'

使用的代码如下:

import griddb_python as griddb

factory = griddb.StoreFactory.get_instance()

# 尝试连接存储
store = factory.get_store(
    notification_address="239.0.0.1",
    notification_port=31999,
    cluster_name="defaultCluster",
    username="admin",
    password="admin"
)

# 创建容器
conInfo = griddb.ContainerInfo("SampleContainer",
                               [["name", griddb.Type.STRING],
                                ["status", griddb.Type.BOOL]],
                               griddb.ContainerType.COLLECTION, True)
container = store.put_container(conInfo)

已执行步骤:

  • 使用pip安装griddb-python
  • 安装pandas等必要依赖
  • 运行上述代码连接GridDB存储

环境信息:

OS: Ubuntu 22.04
Python version: 3.10

疑问:按官方文档示例写的代码,为什么get_store()不识别notification_address参数?是版本问题还是遗漏了什么?


解决方案

这个错误是因为你使用的notification_address参数名与当前安装的griddb-python版本不兼容,参数名在不同版本中有变更:

  1. 先检查griddb-python版本
    运行以下命令查看当前安装的版本:

    pip show griddb-python
    
  2. 根据版本调整参数

    • 如果是v4.6.x及更早版本:notification_address和notification_port的用法是正确的,若仍报错,建议确认GridDB集群的多播配置是否正常,或尝试升级客户端版本。
    • 如果是v5.0.x及更新版本:参数名已改为notification_member,需要把IP和端口合并成"ip:port"的格式传入,无需分开传notification_port,修改后的连接代码如下:
      store = factory.get_store(
          notification_member="239.0.0.1:31999",
          cluster_name="defaultCluster",
          username="admin",
          password="admin"
      )
      
    • 若使用单节点连接(而非多播模式),可以直接用host和port参数简化连接:
      store = factory.get_store(
          host="127.0.0.1",
          port=31999,
          cluster_name="defaultCluster",
          username="admin",
          password="admin"
      )
      
  3. 版本匹配文档
    确保你参考的官方文档版本与实际安装的griddb-python版本一致,旧版文档的参数名在新版客户端中可能已被废弃或修改。

内容的提问来源于stack exchange,提问作者Chaya De

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.18 22:58:19