griddb / python_client

GridDB Python Client
Apache License 2.0
51 stars 61 forks source link

Cannot interact with Partitioned Tables #29

Closed Imisrael closed 8 months ago

Imisrael commented 1 year ago

I have a partitioned table made with the GridDB CLI, but when I try to interact with it via Python NoSQL, it results in an error:

gs[public]> showcontainer myIntervalPartition4
Database    : public
Name        : myIntervalPartition4
Type        : COLLECTION
Partition ID: 19
DataAffinity: -
Partitioned : true
Partition Type           : INTERVAL
Partition Column         : date
Partition Interval Value : 30
Partition Interval Unit  : DAY
Expiration Type      : PARTITION
Expiration Time      : 30
Expiration Time Unit : DAY

Columns:
No  Name                  Type            CSTR  RowKey
------------------------------------------------------------------------------
 0  date                  TIMESTAMP(3)    NN    
 1  value                 STRING 

And then some python code (using python 3.10 on Ubuntu 22.04)

import griddb_python as griddb
import numpy as np
import pandas as pd

factory = griddb.StoreFactory.get_instance()
DB_HOST = "127.0.0.1:10001"
DB_CLUSTER = "myCluster"
DB_USER = "admin"
DB_PASS = "admin"

try:
    # (1) Connect to GridDB
    # Fixed list method
    gridstore = factory.get_store(
        notification_member=DB_HOST, cluster_name=DB_CLUSTER, username=DB_USER, password=DB_PASS)

    container_name = "myIntervalPartition4"
    partition_container = gridstore.get_container(container_name)
    print("Succesfully connected to GridDB!")

    if partition_container == None:
        print("ERROR Container not found: " + container_name)

    query = partition_container.query("SELECT *")
    rs = query.fetch()
    while rs.has_next():
        row = rs.next()
        print(row)

except griddb.GSException as e:
    for i in range(e.get_error_stack_size()):
        print("[", i, "]")
        print(e.get_error_code(i))
        print(e.get_location(i))
        print(e.get_message(i))

Succesfully connected to GridDB! ERROR Container not found: myIntervalPartition4

knonomura commented 8 months ago

Unfortunately GridDB Python Client doesn't support operations for Partitioned Tables.

Could you use GridDB Java Client/JDBC Driver for Partitioned Tables ?