[Python] How to perform range queries on timestamp fields in GridDB Cloud using Python client?

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

  1. Stack

    Stack Membro Participativo

    I'm working on a time-series application in GridDB Cloud and trying to filter records based on a time range using the Python client. I have a container with a timestamp field created_at, and I want to fetch all rows where created_at is between two datetime values.

    Here's the setup:

    from griddb_python import *
    GRIDD_HOST = "my-cluster"
    factory = StoreFactory.get_instance()
    store = factory.get_store(host=GRIDD_HOST, port=10001, cluster_name="defaultCluster", username="admin", password="admin")
    container = store.get_container("sensor_data")
    query = container.query("SELECT * WHERE created_at >= TIMESTAMP('2024-01-01T00:00:00.000Z') AND created_at < TIMESTAMP('2024-01-02T00:00:00.000Z')")

    rs = query.fetch()

    Continue reading...

Compartilhe esta Página