Added utils.WriteOption and refactor, added enablePublicDashb0oard

This commit is contained in:
Paulo Truta
2021-06-20 22:04:12 +00:00
parent 380172f6f0
commit 4614a0f070
3 changed files with 36 additions and 96 deletions
+24
View File
@@ -3,6 +3,7 @@ package utils
import (
"bufio"
"bytes"
"database/sql"
"fmt"
"io"
"log"
@@ -145,3 +146,26 @@ func GetPath(pathKey string) string {
return targetPath
}
func WriteOption(optionKey string, optionValue string) {
db, err := sql.Open("sqlite3", GetSQLiteDbConnectionDetails())
if err != nil {
log.Fatal(err.Error())
}
statement, err := db.Prepare("REPLACE into option (name, value, created, updated) VALUES (?, ?, ?, ?);") // Prepare SQL Statement
if err != nil {
log.Fatal(err.Error())
}
formatedDatetime := GetSQLiteFormattedDateTime(time.Now())
_, err = statement.Exec(optionKey, optionValue, formatedDatetime, formatedDatetime) // Execute SQL Statement
if err != nil {
log.Fatal(err.Error())
}
db.Close()
}