Skip to content

H #12

@rakib06

Description

@rakib06

pip install streamlit pandas plotly tableauhyperapi

import streamlit as st
import pandas as pd
import plotly.express as px

from tableauhyperapi import HyperProcess, Connection

DATABASE = "test.hyper"

st.title("Hyper File Explorer")

query = st.text_area(
    "SQL Query",
    "SELECT * FROM Extract.Extract LIMIT 100"
)

if st.button("Run Query"):

    with HyperProcess() as hyper:
        with Connection(
            endpoint=hyper.endpoint,
            database=DATABASE
        ) as connection:

            rows = connection.execute_list_query(query)

            columns = [desc.name for desc in connection.catalog.get_table_definition(
                "Extract.Extract"
            ).columns]

    df = pd.DataFrame(rows, columns=columns)

    st.dataframe(df)

    if len(df.columns) >= 2:
        x_col = st.selectbox("X Axis", df.columns)
        y_col = st.selectbox("Y Axis", df.columns)

        fig = px.bar(df, x=x_col, y=y_col)

        st.plotly_chart(fig)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions