Jon Solow commited on
Commit
8569c62
·
1 Parent(s): b9bcaf8

Replace data load page with dbt data

Browse files
src/pages/98_Load_Data copy.py DELETED
@@ -1,33 +0,0 @@
1
- import streamlit as st
2
-
3
- from config import DEFAULT_ICON
4
- from shared_page import common_page_config
5
-
6
- from dbt_data_client import run_dbt_build, get_current_tables, execute_db_command_df
7
-
8
-
9
- def get_page():
10
- page_title = "Data Loader - dbt"
11
- st.set_page_config(page_title=page_title, page_icon=DEFAULT_ICON, layout="wide")
12
- common_page_config()
13
- st.title(page_title)
14
-
15
- if st.button("Refresh Data"):
16
- run_dbt_build()
17
-
18
- current_tables_list = get_current_tables()
19
-
20
- if selected_table := st.selectbox("Describe a table:", current_tables_list, index=0):
21
- describe_df = execute_db_command_df(f"DESCRIBE {selected_table}")
22
- st.dataframe(
23
- describe_df,
24
- hide_index=True,
25
- use_container_width=True,
26
- )
27
-
28
- if st.checkbox("Explore data"):
29
- st.dataframe(execute_db_command_df(f"SELECT * FROM {selected_table} LIMIT 50"))
30
-
31
-
32
- if __name__ == "__main__":
33
- get_page()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
src/pages/98_Load_Data.py CHANGED
@@ -1,26 +1,24 @@
1
- import duckdb
2
  import streamlit as st
3
 
4
  from config import DEFAULT_ICON
5
  from shared_page import common_page_config
6
 
7
- from queries.nflverse.github_data import load_assets, get_current_tables
8
 
9
 
10
  def get_page():
11
- page_title = "Data Loader"
12
  st.set_page_config(page_title=page_title, page_icon=DEFAULT_ICON, layout="wide")
13
  common_page_config()
14
  st.title(page_title)
15
 
16
- current_tables_list = get_current_tables()
17
-
18
  if st.button("Refresh Data"):
19
- load_assets()
20
- st.rerun()
 
21
 
22
  if selected_table := st.selectbox("Describe a table:", current_tables_list, index=0):
23
- describe_df = duckdb.sql(f"DESCRIBE {selected_table}").df()
24
  st.dataframe(
25
  describe_df,
26
  hide_index=True,
@@ -28,7 +26,7 @@ def get_page():
28
  )
29
 
30
  if st.checkbox("Explore data"):
31
- st.dataframe(duckdb.sql(f"SELECT * FROM {selected_table} LIMIT 50").df())
32
 
33
 
34
  if __name__ == "__main__":
 
 
1
  import streamlit as st
2
 
3
  from config import DEFAULT_ICON
4
  from shared_page import common_page_config
5
 
6
+ from dbt_data_client import run_dbt_build, get_current_tables, execute_db_command_df
7
 
8
 
9
  def get_page():
10
+ page_title = "Data Loader - dbt"
11
  st.set_page_config(page_title=page_title, page_icon=DEFAULT_ICON, layout="wide")
12
  common_page_config()
13
  st.title(page_title)
14
 
 
 
15
  if st.button("Refresh Data"):
16
+ run_dbt_build()
17
+
18
+ current_tables_list = get_current_tables()
19
 
20
  if selected_table := st.selectbox("Describe a table:", current_tables_list, index=0):
21
+ describe_df = execute_db_command_df(f"DESCRIBE {selected_table}")
22
  st.dataframe(
23
  describe_df,
24
  hide_index=True,
 
26
  )
27
 
28
  if st.checkbox("Explore data"):
29
+ st.dataframe(execute_db_command_df(f"SELECT * FROM {selected_table} LIMIT 50"))
30
 
31
 
32
  if __name__ == "__main__":