#!/usr/bin/env python3
"""Check database data"""
import asyncio
from src.data.models import get_db
from sqlalchemy import text
async def check_data():
try:
async with get_db() as session:
# Check contracts
result = await session.execute(text('SELECT COUNT(*) FROM contracts'))
contract_count = result.scalar()
# Check trades
result = await session.execute(text('SELECT COUNT(*) FROM trades'))
trade_count = result.scalar()
print(f'📊 Database has {contract_count} contracts and {trade_count} trades')
if contract_count > 0:
# Show some sample contracts
result = await session.execute(text('SELECT symbol, description FROM contracts LIMIT 5'))
print('\n📝 Sample contracts:')
for row in result:
print(f' {row[0]}: {row[1]}')
else:
print('⚠️ No contracts found - database may need initialization')
if trade_count > 0:
# Show some sample trades
result = await session.execute(text('SELECT trade_id, price, volume FROM trades LIMIT 5'))
print('\n💰 Sample trades:')
for row in result:
print(f' {row[0]}: ${row[1]} x {row[2]}')
else:
print('⚠️ No trades found - may need to fetch CME data')
except Exception as e:
print(f'❌ Database query error: {e}')
if __name__ == "__main__":
asyncio.run(check_data())