Spaces:
Runtime error
Runtime error
Commit
•
5ad3c2f
1
Parent(s):
09a6ab5
UDPDATE app.py to contain local databases
Browse files
app.py
CHANGED
@@ -6,24 +6,27 @@ st.set_page_config(
|
|
6 |
page_title='DataBoard' ,
|
7 |
page_icon= plt.imread(os.path.abspath('static/logo.png')),
|
8 |
)
|
9 |
-
st.sidebar.title('DataBases')
|
10 |
|
11 |
-
cnx = get_connection(user=st.secrets.db_username, password=st.secrets.db_password, host=st.secrets.db_host)
|
12 |
|
13 |
-
if '
|
|
|
|
|
|
|
|
|
|
|
14 |
databases = [db[0] for db in get_database_names(cnx)]
|
15 |
st.session_state.databases = databases
|
16 |
|
|
|
17 |
def on_table_radio_change(db_name) :
|
18 |
if db_name in st.session_state :
|
19 |
table_selected = st.session_state.get(db_name)
|
20 |
-
st.
|
21 |
st.dataframe(get_table_in_database(cnx,db_name = db_name, table_name= table_selected))
|
22 |
|
23 |
|
24 |
-
|
25 |
-
|
26 |
-
with st.sidebar :
|
27 |
for db in st.session_state.databases :
|
28 |
with st.expander(db) :
|
29 |
tables = get_all_tables_in_database(cnx, db)
|
|
|
6 |
page_title='DataBoard' ,
|
7 |
page_icon= plt.imread(os.path.abspath('static/logo.png')),
|
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 |
+
st.sidebar.title('DataBases')
|
29 |
+
with st.sidebar:
|
|
|
30 |
for db in st.session_state.databases :
|
31 |
with st.expander(db) :
|
32 |
tables = get_all_tables_in_database(cnx, db)
|