最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Issue with Python GridDB: Unable to fetch rows - "Row data does not match container definition" - Stack Overfl

programmeradmin6浏览0评论

I’m developing a Python application that interacts with a GridDB time-series container. While inserting and querying data, I encountered an issue where the container fails to retrieve rows. The error message I receive is: gs.error.GSException: [101503:API] Row data does not match container definition

Here’s the Python code I’m using:

from griddb_python import ContainerInfo, GSException, Timestamp

factory = griddb_python.StoreFactory.get_instance()

try:
    # Connect to GridDB
    gridstore = factory.get_store(
        host="239.0.0.1",
        port=31999,
        cluster_name="defaultCluster",
        username="admin",
        password="admin"
    )

    # Create a time-series container
    container_info = ContainerInfo(
        name="device_logs",
        column_info_list=[
            ("log_time", griddb_python.Type.TIMESTAMP),
            ("device_id", griddb_python.Type.STRING),
            ("status", griddb_python.Type.INTEGER)
        ],
        type=griddb_python.ContainerType.TIME_SERIES
    )
    container = gridstore.put_container(container_info)

    # Insert data
    ts = container
    ts.put([Timestamp(2024, 11, 21, 10, 0, 0), "device123", "active"])

    # Query data
    query = ts.query("SELECT *")
    rowset = query.fetch()

    # Print results
    while rowset.has_next():
        data = rowset.next()
        print("Data:", data)

except GSException as e:
    print("Error occurred:", e)

I suspect the issue lies in the data format, specifically when inserting rows. I’ve reviewed the container definition and ensured the columns match the data being inserted, but the error persists.

-Am I missing something in the way I’m defining the container or inserting the data? -Is there a specific way to handle data types in Python for GridDB to avoid such issues? Any advice or insights would be greatly appreciated!

发布评论

评论列表(0)

  1. 暂无评论