mirror of
https://github.com/aljazceru/hummingbot-dashboard.git
synced 2025-12-30 03:24:28 +01:00
(fix) database fixed error
This commit is contained in:
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user