DataAccess: use INSERT OR IGNORE for DailyAPICount to prevent UNIQUE constraint
This commit is contained in:
@@ -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());
|
||||||
|
|||||||
Reference in New Issue
Block a user