#!/usr/bin/env python3
"""
Simple database query test
"""

import sys
sys.path.insert(0, '/app')

from src.api.database import MusicBrainzDatabase

def test_simple_query():
    db = MusicBrainzDatabase()
    
    if not db.connect():
        print("❌ Could not connect to database")
        return
    
    print("✅ Connected to database")
    
    # Test a simple query
    try:
        db.cursor.execute("SELECT COUNT(*) FROM artist")
        count = db.cursor.fetchone()
        print(f"📊 Total artists in database: {count['count']:,}")
        
        # Test specific artist query
        db.cursor.execute("SELECT name, gid FROM artist WHERE name = %s LIMIT 1", ('Ariana Grande',))
        result = db.cursor.fetchone()
        if result:
            print(f"✅ Found Ariana Grande: {result['name']} (MBID: {result['gid']})")
        else:
            print("❌ Ariana Grande not found")
            
        # Test SZA
        db.cursor.execute("SELECT name, gid FROM artist WHERE name = %s LIMIT 1", ('SZA',))
        result = db.cursor.fetchone()
        if result:
            print(f"✅ Found SZA: {result['name']} (MBID: {result['gid']})")
        else:
            print("❌ SZA not found")
            
    except Exception as e:
        print(f"❌ Error: {e}")
        import traceback
        traceback.print_exc()

if __name__ == "__main__":
    test_simple_query() 