[Python] Is there a way to achieve near-instant updates in Streamlit using GridDB as a...

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

  1. Stack

    Stack Membro Participativo

    I'm working on a real-time monitoring dashboard using Streamlit, with GridDB as the backend time-series database. My goal is to update the dashboard with new data every second.

    Here is my current setup:

    I'm using the griddb_python_client to connect and query GridDB. The dashboard refreshes periodically using st.experimental_rerun() to display the most recent data.

    However, I'm running into a limitation:

    GridDB does not provide a native pub/sub mechanism or event triggers to notify the application when new data is inserted. This forces me to rely on polling, which is not efficient.

    Could there be a smarter or more efficient way to integrate GridDB with Streamlit for near-instant or real-time updates — ideally without resorting to constant polling?

    Here is a snippet of my code

    def get_latest_data():
    query = container.query("SELECT * WHERE timestamp > TIMESTAMPADD(SECOND, -5, NOW())")
    rs = query.fetch()
    return [rs.get_next() for _ in range(rs.size())]

    st.title("Real-time Dashboard")

    data = get_latest_data()

    st.write(data)

    time.sleep(1)
    st.experimental_rerun()

    Continue reading...

Compartilhe esta Página