From ed92133f544e6e38ff963e2dbe762b2c8be0b0c0 Mon Sep 17 00:00:00 2001 From: Dmitry Ganyushin Date: Mon, 19 Feb 2024 17:38:15 -0500 Subject: [PATCH] If table exists, it will be updated --- source/adios2/engine/campaign/CampaignManager.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/source/adios2/engine/campaign/CampaignManager.cpp b/source/adios2/engine/campaign/CampaignManager.cpp index 5a218b68b8..0289a07a0b 100644 --- a/source/adios2/engine/campaign/CampaignManager.cpp +++ b/source/adios2/engine/campaign/CampaignManager.cpp @@ -30,7 +30,7 @@ int CMapToSqlite(const CampaignRecordMap &cmap, const int rank, std::string name { sqlite3 *db; int rc; - char *zErrMsg = 0; + char *zErrMsg = nullptr; std::string sqlcmd; std::string db_name = name + ".db"; rc = sqlite3_open(db_name.c_str(), &db); @@ -43,7 +43,7 @@ int CMapToSqlite(const CampaignRecordMap &cmap, const int rank, std::string name "SQL error on writing records:"); sqlite3_free(zErrMsg); } - sqlcmd = "CREATE TABLE bpfiles (name);"; + sqlcmd = "CREATE TABLE if not exists bpfiles (name);"; rc = sqlite3_exec(db, sqlcmd.c_str(), 0, 0, &zErrMsg); if (rc != SQLITE_OK) { @@ -57,8 +57,8 @@ int CMapToSqlite(const CampaignRecordMap &cmap, const int rank, std::string name size_t rowid = 1000; for (auto &r : cmap) { - sqlcmd = "INSERT INTO bpfiles (rowid, name)\n"; - sqlcmd += "VALUES(" + std::to_string(rowid) + "," + "'" + r.first + "'" + ");"; + sqlcmd = "INSERT INTO bpfiles (name)\n"; + sqlcmd += "VALUES('" + r.first + "');"; rowid++; rc = sqlite3_exec(db, sqlcmd.c_str(), 0, 0, &zErrMsg); if (rc != SQLITE_OK)