update 03-28 11:38
This commit is contained in:
@@ -352,10 +352,8 @@ def query_db(db_path: Path, sql: str) -> pd.DataFrame:
|
||||
if not db_path.exists():
|
||||
return pd.DataFrame()
|
||||
try:
|
||||
conn = sqlite3.connect(str(db_path))
|
||||
df = pd.read_sql_query(sql, conn)
|
||||
conn.close()
|
||||
return df
|
||||
with sqlite3.connect(str(db_path)) as conn:
|
||||
return pd.read_sql_query(sql, conn)
|
||||
except Exception:
|
||||
return pd.DataFrame()
|
||||
|
||||
@@ -389,11 +387,11 @@ refresh_rate = st.sidebar.selectbox("Interval (sec)", [5, 10, 30], index=1, labe
|
||||
auto_refresh = st.sidebar.checkbox("Auto-refresh", value=True)
|
||||
|
||||
# Load data
|
||||
trades_df = query_db(db_path, "SELECT * FROM trades ORDER BY created_at DESC")
|
||||
windows_df = query_db(db_path, "SELECT * FROM window_snapshots ORDER BY created_at DESC")
|
||||
daily_df = query_db(db_path, "SELECT * FROM daily_summary ORDER BY date DESC")
|
||||
balance_df = query_db(db_path, "SELECT * FROM balance_history ORDER BY timestamp ASC")
|
||||
oracle_df = query_db(db_path, "SELECT * FROM oracle_snapshots ORDER BY timestamp DESC")
|
||||
trades_df = query_db(db_path, "SELECT * FROM trades ORDER BY created_at DESC LIMIT 500")
|
||||
windows_df = query_db(db_path, "SELECT * FROM window_snapshots ORDER BY created_at DESC LIMIT 1000")
|
||||
daily_df = query_db(db_path, "SELECT * FROM daily_summary ORDER BY date DESC LIMIT 90")
|
||||
balance_df = query_db(db_path, "SELECT * FROM (SELECT * FROM balance_history ORDER BY timestamp DESC LIMIT 2000) ORDER BY timestamp ASC")
|
||||
oracle_df = query_db(db_path, "SELECT * FROM (SELECT * FROM oracle_snapshots ORDER BY timestamp DESC LIMIT 2000) ORDER BY timestamp ASC")
|
||||
|
||||
|
||||
# ==================================================================
|
||||
|
||||
Reference in New Issue
Block a user