diff --git a/pages/4_🫙_Hummingbot_DB.py b/pages/4_🫙_Hummingbot_DB.py index 335f5bc..884c297 100644 --- a/pages/4_🫙_Hummingbot_DB.py +++ b/pages/4_🫙_Hummingbot_DB.py @@ -4,14 +4,14 @@ import sqlite3 import pandas as pd @st.cache(suppress_st_warning=True, allow_output_mutation=True) -def get_table_data(table_name: str): - conn = sqlite3.connect('hummingbot_db.sqlite') +def get_table_data(database_name: str, table_name: str): + conn = sqlite3.connect(database_name) orders = pd.read_sql_query(f"SELECT * FROM '{table_name}'", conn) return orders @st.cache(suppress_st_warning=True, allow_output_mutation=True) -def get_all_tables(): - con = sqlite3.connect('hummingbot_db.sqlite') +def get_all_tables(database_name: str): + con = sqlite3.connect(database_name) cursor = con.cursor() cursor.execute("SELECT name FROM sqlite_master WHERE type='table';") tables = [table_row[0] for table_row in cursor.fetchall()] @@ -23,10 +23,10 @@ st.write("---") uploaded_file = st.file_uploader("Add your database") if uploaded_file is not None: - with open("hummingbot_db.sqlite", "wb") as f: + with open(f"{uploaded_file.name}", "wb") as f: f.write(uploaded_file.getbuffer()) - tables = get_all_tables() + tables = get_all_tables(uploaded_file.name) st.subheader("Tables of the database:") for table in tables: st.write(table) - st.dataframe(get_table_data(table)) + st.dataframe(get_table_data(uploaded_file.name, table))