about summary refs log tree commit diff stats
path: root/src/sqliteinterface.cpp
diff options
context:
space:
mode:
authorComradeCrow <comradecrow@vivaldi.net>2023-05-17 23:25:10 -0700
committerComradeCrow <comradecrow@vivaldi.net>2023-05-17 23:25:10 -0700
commitdd9811703ad623e6b3ddc51e58ef5cc801f41951 (patch)
tree7c10fbd421919cbf2ff19fd3454445790102e6c1 /src/sqliteinterface.cpp
parent8b4fa2a3b6b1a3d75fd4ae5a61266e159d22e095 (diff)
downloadytcpp-dd9811703ad623e6b3ddc51e58ef5cc801f41951.tar.gz
save to db is working
Diffstat (limited to 'src/sqliteinterface.cpp')
-rw-r--r--src/sqliteinterface.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/sqliteinterface.cpp b/src/sqliteinterface.cpp
index c34576b..e59fd8a 100644
--- a/src/sqliteinterface.cpp
+++ b/src/sqliteinterface.cpp
@@ -66,10 +66,11 @@ void SqliteInterface::createTables() {
    }
 }
 
-void SqliteInterface::saveInstance(const string& uri, float health, const string& location) {
+void SqliteInterface::saveInstance(const  char *uri, float health, const  char *location) {
 
     char *errmsg = 0;
-    int rc = sqlite3_exec(db, sqlite3_mprintf("INSERT INTO INSTANCES (%Q, %F.2, %Q)", uri, health, location), callback, 0, &errmsg);
+    char *sqlExec = sqlite3_mprintf("REPLACE INTO INSTANCES VALUES(%Q, '%.3f', %Q);", uri, health, location);
+    int rc = sqlite3_exec(db, sqlExec, callback, 0, &errmsg);
     if( rc != SQLITE_OK ){
         fprintf(stderr, "SQL error: %s\n", errmsg);
         sqlite3_free(errmsg);