Spaces:
Runtime error
Runtime error
sajjadyazdanparast
commited on
Commit
•
ca85a0d
1
Parent(s):
5ad3c2f
ADD app.py to display dataframs. UPDATE database folder
Browse files- app.py +11 -27
- database/dataframes/cars_raw.csv +0 -0
- database/dataframes/notifications_pushe.csv +0 -0
- database/dataframes/unidro_data.csv +0 -0
app.py
CHANGED
@@ -8,38 +8,22 @@ st.set_page_config(
|
|
8 |
)
|
9 |
|
10 |
|
11 |
-
if st.checkbox('Use remote database?') :
|
12 |
-
cnx = get_connection(user=st.secrets.db_username, password=st.secrets.db_password, host=st.secrets.db_host)
|
13 |
-
databases = [db[0] for db in get_database_names(cnx)]
|
14 |
-
st.session_state.databases = databases
|
15 |
-
else :
|
16 |
-
cnx = get_connection(user='sajjad_quera', password="P@ssword1401", host='localhost')
|
17 |
-
databases = [db[0] for db in get_database_names(cnx)]
|
18 |
-
st.session_state.databases = databases
|
19 |
-
|
20 |
-
|
21 |
def on_table_radio_change(db_name) :
|
22 |
if db_name in st.session_state :
|
23 |
table_selected = st.session_state.get(db_name)
|
24 |
st.subheader(f'{table_selected} table from {db_name} database dashboarding')
|
25 |
st.dataframe(get_table_in_database(cnx,db_name = db_name, table_name= table_selected))
|
26 |
|
|
|
27 |
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
with st.expander(db) :
|
32 |
-
tables = get_all_tables_in_database(cnx, db)
|
33 |
-
tables = [table[0] for table in tables]
|
34 |
-
|
35 |
-
table_selected = st.radio(
|
36 |
-
label = 'tables',
|
37 |
-
options= tables,
|
38 |
-
label_visibility='collapsed' ,
|
39 |
-
key = db ,
|
40 |
-
on_change = on_table_radio_change,
|
41 |
-
kwargs={"db_name" : db}
|
42 |
-
|
43 |
-
)
|
44 |
-
|
45 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
)
|
9 |
|
10 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
def on_table_radio_change(db_name) :
|
12 |
if db_name in st.session_state :
|
13 |
table_selected = st.session_state.get(db_name)
|
14 |
st.subheader(f'{table_selected} table from {db_name} database dashboarding')
|
15 |
st.dataframe(get_table_in_database(cnx,db_name = db_name, table_name= table_selected))
|
16 |
|
17 |
+
st.session_state.dfs = os.listdir(os.path.abspath('database/dataframes'))
|
18 |
|
19 |
+
def on_selectbox_change() :
|
20 |
+
df = pd.read_csv(os.path.abspath('database/dataframes')+'\\'+st.session_state.df_name)
|
21 |
+
st.dataframe(df)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
|
23 |
+
st.sidebar.title('DataFrames')
|
24 |
+
with st.sidebar:
|
25 |
+
st.selectbox(label='Which dataframe to display?',
|
26 |
+
options=st.session_state.dfs,
|
27 |
+
on_change=on_selectbox_change,
|
28 |
+
key='df_name',
|
29 |
+
)
|
database/dataframes/cars_raw.csv
ADDED
The diff for this file is too large to render.
See raw diff
|
|
database/dataframes/notifications_pushe.csv
ADDED
The diff for this file is too large to render.
See raw diff
|
|
database/dataframes/unidro_data.csv
ADDED
The diff for this file is too large to render.
See raw diff
|
|