[Python] How to filter timestamp ranges in GridDB Cloud using Python client?

Discussão em 'Python' iniciado por Stack, Junho 13, 2025.

  1. Stack

    Stack Membro Participativo

    I'm using GridDB Cloud for a time-series application and working with the official Python client. I have a container named sensor_data that includes a created_at field of type TIMESTAMP.

    I want to run a query to retrieve all rows where created_at is between two specific datetime values.

    from griddb_python import *

    GRID_HOST = "your_cluster_host" factory = StoreFactory.get_instance() store = factory.get_store(host=GRID_HOST, port=10001, cluster_name="defaultCluster", username="admin", password="admin")

    container = store.get_container("sensor_data")

    Attempting to fetch rows between two timestamps


    query = container.query( "SELECT * FROM sensor_data WHERE created_at >= TIMESTAMP('2023-01-01T00:00:00Z') AND created_at <= TIMESTAMP('2024-01-01T00:00:00Z')" )

    rs = query.fetch()

    Problem:

    When I run this query, I don't get the expected results — the result set is empty, even though I know the container contains data in that time range.

    I've reviewed the GridDB TQL documentation, but couldn't confirm whether my syntax or approach is correct for timestamp filtering in GridDB using the Python client.

    My Questions:

    Is this the correct way to filter by TIMESTAMP range in GridDB Cloud using the Python client? Does GridDB require a specific datetime format or indexing setup for time-based queries to work? Am I missing a step like setting time zone, formatting, or container indexing?

    Continue reading...

Compartilhe esta Página