import sqlite3
import json
DB_PATH = r"C:\Users\miche\AppData\Roaming\com.teymz.wealthfolio\app.db"
conn = sqlite3.connect(DB_PATH)
cursor = conn.cursor()
# Check accounts
cursor.execute('SELECT id, name, account_type, "group", is_active FROM accounts ORDER BY "group", name')
accounts = cursor.fetchall()
print(f"=== ACCOUNTS ({len(accounts)} total) ===\n")
for acc in accounts:
status = "ACTIVE" if acc[4] == 1 else "INACTIVE"
print(f"{acc[0][:35]:35} | {acc[1][:30]:30} | {acc[2]:15} | Group: {acc[3] or 'NULL':15} | {status}")
# Check latest daily valuations for TOTAL
print("\n=== LATEST TOTAL VALUATIONS ===\n")
cursor.execute('''
SELECT valuation_date, total_value, investment_market_value, cash_balance
FROM daily_account_valuation
WHERE account_id = 'TOTAL'
ORDER BY valuation_date DESC
LIMIT 5
''')
valuations = cursor.fetchall()
for val in valuations:
try:
print(f"{val[0]} | Total: {float(val[1]):12.2f} | Investments: {float(val[2]):12.2f} | Cash: {float(val[3]):12.2f}")
except:
print(f"{val[0]} | Total: {val[1]} | Investments: {val[2]} | Cash: {val[3]}")
# Check holdings snapshots
print("\n=== HOLDINGS SNAPSHOTS ===\n")
cursor.execute('''
SELECT account_id, snapshot_date, LENGTH(positions) as positions_size, LENGTH(cash_balances) as cash_size
FROM holdings_snapshots
ORDER BY snapshot_date DESC
LIMIT 10
''')
snapshots = cursor.fetchall()
for snap in snapshots:
print(f"{snap[0][:35]:35} | {snap[1]} | Positions JSON: {snap[2]} bytes | Cash JSON: {snap[3]} bytes")
# Check assets count
cursor.execute('SELECT COUNT(*) FROM assets WHERE asset_type != "Currency"')
asset_count = cursor.fetchone()[0]
print(f"\n=== ASSETS ===\n")
print(f"Total non-currency assets: {asset_count}")
conn.close()