1.2.0: Refined all 6D calcs and UI/UX Experiences.
This commit is contained in:
@@ -1,65 +1,63 @@
|
||||
import sqlite3
|
||||
import pandas as pd
|
||||
import os
|
||||
|
||||
# Define database paths
|
||||
BASE_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
|
||||
L2_PATH = os.path.join(BASE_DIR, 'database', 'L2', 'L2_Main.sqlite')
|
||||
|
||||
def check_l2_tables():
|
||||
print(f"Checking L2 database at: {L2_PATH}")
|
||||
if not os.path.exists(L2_PATH):
|
||||
print("Error: L2 database not found!")
|
||||
return
|
||||
L2_PATH = r'd:\Documents\trae_projects\yrtv\database\L2\L2_Main.sqlite'
|
||||
WEB_PATH = r'd:\Documents\trae_projects\yrtv\database\Web\Web_App.sqlite'
|
||||
|
||||
def debug_db():
|
||||
# --- L2 Checks ---
|
||||
conn = sqlite3.connect(L2_PATH)
|
||||
cursor = conn.cursor()
|
||||
|
||||
cursor.execute("SELECT name FROM sqlite_master WHERE type='table';")
|
||||
tables = cursor.fetchall()
|
||||
print("Tables in L2 Database:")
|
||||
for table in tables:
|
||||
print(f" - {table[0]}")
|
||||
print("--- Data Source Type Distribution ---")
|
||||
try:
|
||||
df = pd.read_sql_query("SELECT data_source_type, COUNT(*) as cnt FROM fact_matches GROUP BY data_source_type", conn)
|
||||
print(df)
|
||||
except Exception as e:
|
||||
print(f"Error: {e}")
|
||||
|
||||
print("\n--- Economy Table Count ---")
|
||||
try:
|
||||
count = conn.execute("SELECT COUNT(*) FROM fact_round_player_economy").fetchone()[0]
|
||||
print(f"Rows: {count}")
|
||||
except Exception as e:
|
||||
print(f"Error: {e}")
|
||||
|
||||
print("\n--- Check util_flash_usage in fact_match_players ---")
|
||||
try:
|
||||
cursor = conn.cursor()
|
||||
cursor.execute("PRAGMA table_info(fact_match_players)")
|
||||
cols = [info[1] for info in cursor.fetchall()]
|
||||
if 'util_flash_usage' in cols:
|
||||
print("Column 'util_flash_usage' EXISTS.")
|
||||
nz = conn.execute("SELECT COUNT(*) FROM fact_match_players WHERE util_flash_usage > 0").fetchone()[0]
|
||||
print(f"Rows with util_flash_usage > 0: {nz}")
|
||||
else:
|
||||
print("Column 'util_flash_usage' MISSING.")
|
||||
except Exception as e:
|
||||
print(f"Error: {e}")
|
||||
|
||||
conn.close()
|
||||
|
||||
def debug_player_query(player_name_query=None):
|
||||
print(f"\nDebugging Player Query (L2)...")
|
||||
conn = sqlite3.connect(L2_PATH)
|
||||
cursor = conn.cursor()
|
||||
|
||||
# --- Web DB Checks ---
|
||||
print("\n--- Web DB Check ---")
|
||||
if not os.path.exists(WEB_PATH):
|
||||
print(f"Web DB not found at {WEB_PATH}")
|
||||
return
|
||||
|
||||
try:
|
||||
# Check if 'dim_players' exists
|
||||
cursor.execute("SELECT name FROM sqlite_master WHERE type='table' AND name='dim_players';")
|
||||
if not cursor.fetchone():
|
||||
print("Error: 'dim_players' table not found!")
|
||||
return
|
||||
|
||||
# Check schema of dim_players
|
||||
print("\nChecking dim_players schema:")
|
||||
cursor.execute("PRAGMA table_info(dim_players)")
|
||||
for col in cursor.fetchall():
|
||||
print(col)
|
||||
|
||||
# Check sample data
|
||||
print("\nSampling dim_players (first 5):")
|
||||
cursor.execute("SELECT * FROM dim_players LIMIT 5")
|
||||
for row in cursor.fetchall():
|
||||
print(row)
|
||||
|
||||
# Test Search
|
||||
search_term = 'zy'
|
||||
print(f"\nTesting search for '{search_term}':")
|
||||
cursor.execute("SELECT * FROM dim_players WHERE name LIKE ?", (f'%{search_term}%',))
|
||||
results = cursor.fetchall()
|
||||
print(f"Found {len(results)} matches.")
|
||||
for r in results:
|
||||
print(r)
|
||||
|
||||
conn_web = sqlite3.connect(WEB_PATH)
|
||||
cursor = conn_web.cursor()
|
||||
cursor.execute("SELECT name FROM sqlite_master WHERE type='table'")
|
||||
tables = cursor.fetchall()
|
||||
print(f"Tables: {[t[0] for t in tables]}")
|
||||
|
||||
if 'player_metadata' in [t[0] for t in tables]:
|
||||
count = conn_web.execute("SELECT COUNT(*) FROM player_metadata").fetchone()[0]
|
||||
print(f"player_metadata rows: {count}")
|
||||
conn_web.close()
|
||||
except Exception as e:
|
||||
print(f"Error querying L2: {e}")
|
||||
finally:
|
||||
conn.close()
|
||||
print(f"Error checking Web DB: {e}")
|
||||
|
||||
if __name__ == '__main__':
|
||||
check_l2_tables()
|
||||
debug_player_query()
|
||||
if __name__ == "__main__":
|
||||
debug_db()
|
||||
|
||||
Reference in New Issue
Block a user