From de51068d0a9897b3af0d8203e815d6bf299d6451 Mon Sep 17 00:00:00 2001 From: jim Date: Mon, 24 Nov 2025 09:58:20 -0600 Subject: [PATCH] DataAccess: use INSERT OR IGNORE for DailyAPICount to prevent UNIQUE constraint --- URLNotesGrabberCORE/DataAccess.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/URLNotesGrabberCORE/DataAccess.cs b/URLNotesGrabberCORE/DataAccess.cs index e7fb1b3..8536ddb 100644 --- a/URLNotesGrabberCORE/DataAccess.cs +++ b/URLNotesGrabberCORE/DataAccess.cs @@ -194,7 +194,9 @@ namespace URLNotesGrabberCORE { connection.Open(); - string sql = "INSERT INTO DailyAPICount (Date) values(@date)"; + // Use INSERT OR IGNORE to avoid UNIQUE constraint errors when the date row already exists. + // Also explicitly initialize APICount to 0 in case the table has no default. + string sql = "INSERT OR IGNORE INTO DailyAPICount (Date, APICount) values(@date, 0)"; using (SQLiteCommand command = new SQLiteCommand(sql, connection)) { command.Parameters.AddWithValue("@date", DateTime.Today.ToShortDateString());