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

today = '2026-02-24'

# Delete old Grok predictions for today
c.execute('DELETE FROM external_predictions WHERE source = ? AND date = ?', ('grok', today))

# Add new Grok predictions from email
grok_picks = [
    (7, "I'M A BELIEVER", 1, 85),
    (3, 'GRAND BALCON', 2, 70),
    (1, 'PRINCE DE MONTFORT', 3, 65),
]

for num, name, rank, conf in grok_picks:
    c.execute('''INSERT INTO external_predictions (date, source, race_name, horse_name, horse_number, odds, rank, confidence)
                 VALUES (?, ?, ?, ?, ?, ?, ?, ?)''',
              (today, 'grok', 'Quinte Cagnes-sur-Mer', name, num, 0, rank, conf))

conn.commit()
print('Updated Grok!')

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

conn.close()
