import sqlite3
conn = sqlite3.connect('/home/h3r7/turf_scraper/turf.db')
c = conn.cursor()

# Delete duplicate predictions for today (keep only latest)
c.execute('DELETE FROM predictions WHERE date = "2026-02-24"')

# Add clean predictions
preds = [
    (7, "I'M A BELIEVER", 1),
    (1, 'PRINCE DE MONTFORT', 2),
    (3, 'GRAND BALCON', 3),
    (8, 'PAOLINO', 4),
    (11, 'INCREMENTAL', 5),
    (15, 'PRINCESSE SAPHIR', 6),
    (16, 'GOLD PLAYER', 7),
    (14, 'WEEMAGATEE', 8),
]

today = '2026-02-24'
for num, name, rank in preds:
    c.execute('INSERT INTO predictions (date, race_name, horse_number, horse_name, prediction_rank, source) VALUES (?, ?, ?, ?, ?, ?)',
              (today, 'Quinte Cagnes-sur-Mer', num, name, rank, 'canalturf'))

conn.commit()
print('Cleaned!')

c.execute('SELECT horse_number, horse_name, prediction_rank FROM predictions WHERE date = ?', (today,))
for r in c.fetchall():
    print(f"  {r[0]} - {r[1]} (rank {r[2]})")
conn.close()
