Got it working!

This commit is contained in:
Daniel Ledda
2020-11-03 00:02:16 +01:00
parent 856e8723aa
commit 6a36f7ccbe

View File

@@ -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);",
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))
snapshotSub.Timestamp)
fmt.Println(query)
_, err = ClimateDb.Query(query)
if err != nil {
return fmt.Errorf("couldn't submit snapshot into the database: %w", err)
}