From 6a36f7ccbe508477750a6e9248a316054d63e891 Mon Sep 17 00:00:00 2001 From: Daniel Ledda Date: Tue, 3 Nov 2020 00:02:16 +0100 Subject: [PATCH] Got it working! --- climate-server.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/climate-server.go b/climate-server.go index 765704f..bfff0df 100644 --- a/climate-server.go +++ b/climate-server.go @@ -47,12 +47,13 @@ func saveSnapshot(w http.ResponseWriter, r *http.Request) error { if err != nil { return fmt.Errorf("couldn't create snapshot from JSON: %w", err) } - _, err = ClimateDb.Query( - fmt.Sprintf("INSERT INTO `snapshots` (`temp`, `humidity`, `co2`, `time`, `id`) VALUES (%v, %v, %v, %v, NULL);", - snapshotSub.Temp, - snapshotSub.Humidity, - snapshotSub.Co2, - snapshotSub.Timestamp)) + query := fmt.Sprintf("INSERT INTO `snapshots` (`temp`, `humidity`, `co2`, `time`, `id`) VALUES (%v, %v, %v, %v, NULL);", + snapshotSub.Temp, + snapshotSub.Humidity, + snapshotSub.Co2, + snapshotSub.Timestamp) + fmt.Println(query) + _, err = ClimateDb.Query(query) if err != nil { return fmt.Errorf("couldn't submit snapshot into the database: %w", err) }