Almost there

This commit is contained in:
Daniel Ledda
2020-11-14 15:26:45 +01:00
parent 99b7c21c76
commit d2955e53b4
4 changed files with 5 additions and 6 deletions

View File

@@ -2,9 +2,8 @@ package main
import (
"database/sql"
_ "github.com/Freeaqingme/golang-sql-driver-mysql"
"fmt"
"time"
_ "github.com/Freeaqingme/golang-sql-driver-mysql"
)
var ClimateDb *sql.DB
@@ -67,7 +66,7 @@ func getLastSnapshotRecordFromDb() (*SnapshotRecord, error) {
return &snapshotRecord, nil
}
func getSnapshotRecordsFromDb(dateSince time.Time) ([]*SnapshotRecord, error) {
func getSnapshotRecordsFromDb(dateSince string) ([]*SnapshotRecord, error) {
snapshots := make([]*SnapshotRecord, 0)
query := "SELECT `%s`, `%s`, `%s`, `%s`, `%s` FROM `snapshots` WHERE `%s` > %s ORDER BY `id` DESC;"
rows, err := ClimateDb.Query(fmt.Sprintf(query, "id", "temp", "humidity", "co2", "time", "time", dateSince))