[Python] Unable to Add Columns to Existing Container in GridDB Python Client

Discussão em 'Python' iniciado por Stack, Maio 1, 2025.

  1. Stack

    Stack Membro Participativo

    I have an existing GridDB container created with the Python client:

    from griddb_python import griddb

    factory = griddb.StoreFactory.get_instance()
    gridstore = factory.get_store(
    host="127.0.0.1", port=31999,
    cluster_name="defaultCluster",
    username="admin", password="admin"
    )

    con_info = griddb.ContainerInfo(
    "Users",
    [["id", griddb.Type.INTEGER], ["name", griddb.Type.STRING]],
    griddb.ContainerType.COLLECTION, True
    )
    container = gridstore.put_container(con_info)
    container.put([1, "Abdullah"])


    Later I realize I need to add a new column "age" to the Users container to store user ages. I tried updating the ContainerInfo and calling put_container again:

    new_con_info = griddb.ContainerInfo(
    "Users",
    [["id", griddb.Type.INTEGER], ["name", griddb.Type.STRING], ["age", griddb.Type.INTEGER]],
    griddb.ContainerType.COLLECTION, True
    )
    new_container = gridstore.put_container(new_con_info)


    There does not appear to be a method like add_column in the Python API. Is it possible to alter a GridDB container’s schema like add or remove? after creation via the Python client? If not, what is the recommended way to evolve my data schema in GridDB?

    GSException: (code: -8, message: Container already exists)

    Continue reading...

Compartilhe esta Página