Spaces:
Sleeping
Sleeping
File size: 1,088 Bytes
2a27c15 ddf7165 2a27c15 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
import streamlit as st
from config import DEFAULT_ICON
from shared_page import common_page_config
from dbt_data_client import get_db_conn, run_dbt_build, get_current_tables
def get_page():
page_title = "Data Loader - dbt"
st.set_page_config(page_title=page_title, page_icon=DEFAULT_ICON, layout="wide")
common_page_config()
st.title(page_title)
with get_db_conn() as duckdb_conn:
current_tables_list = get_current_tables(duckdb_conn)
if st.button("Refresh Data"):
run_dbt_build()
if selected_table := st.selectbox("Describe a table:", current_tables_list, index=0):
with get_db_conn() as duckdb_conn:
describe_df = duckdb_conn.sql(f"DESCRIBE {selected_table}").df()
st.dataframe(
describe_df,
hide_index=True,
use_container_width=True,
)
if st.checkbox("Explore data"):
with get_db_conn() as duckdb_conn:
st.dataframe(duckdb_conn.sql(f"SELECT * FROM {selected_table} LIMIT 50").df())
if __name__ == "__main__":
get_page()
|