DataAccess: use INSERT OR IGNORE for DailyAPICount to prevent UNIQUE constraint

This commit is contained in:
jim
2025-11-24 09:58:20 -06:00
parent 2640854f79
commit de51068d0a
+3 -1
View File
@@ -194,7 +194,9 @@ namespace URLNotesGrabberCORE
{ {
connection.Open(); 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)) using (SQLiteCommand command = new SQLiteCommand(sql, connection))
{ {
command.Parameters.AddWithValue("@date", DateTime.Today.ToShortDateString()); command.Parameters.AddWithValue("@date", DateTime.Today.ToShortDateString());